连接变量的奇怪问题

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!

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.

Is your variable $string containing a HTML tag, something like <p></p> or else ? This could be "hidden" if you print_r it inside a browser.