I did not find a statement about string and null compatibility in documents, but tried this in PHP 5.5:
echo 'foo' . null . 'bar';
prints foobar .
I wonder if this behavior is guaranteed or “safe” (in SQL, for example, this is not so)? Or ask for another way: should I ever check for null before concatenating strings? how
echo 'foo' . (($mystring === null) ? '' : $mystring) . 'bar';
source share