Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird issue with concatenate variables

Tags:

php

I am a weird issue regarding my class property here

I have the following:

$this->tableData = '<table>';

$this->tableData .= $string;

echo $this->tableData   => output <table>

I want to concatenate more string to my $this->tableData but it seems like nothing is added.

I know $string is not null and contains characters

Did I do something wrong here?

Thanks!

like image 425
FlyingCat Avatar asked Jan 01 '26 04:01

FlyingCat


1 Answers

To see if your string is not null you should use var_dump() or print_r() functions.

Example:

$this->tableData = '<table>';
echo "Dumping tableData: " . var_dump($this->tableData);

$this->tableData .= $string;
echo "Dumping tableData 2: " . var_dump($this->tableData);
echo "Dumping string: " . var_dump($string);

That way you will see exactly what is going on.

like image 111
JorgeeFG Avatar answered Jan 02 '26 19:01

JorgeeFG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!