I\'m calling either var_dump()
or print_r()
on an array that has one value in an echo
statement:
echo \"
<
You can use the comma operator instead of the dot operator:
echo "<pre>" . var_dump($cal) . "</pre>";
object(Calendar)#2
<pre>
</pre>
echo "<pre>" , var_dump($cal) , "</pre>";
<pre>object(Calendar)#2
</pre>
They do it because they aren't returning data, they are echoing. You can do print_r($array, true)
to make it return, but var_dump() will need output buffering.
If you want it to work the way you're trying to make it, separate them into distinct calls.
var_dump
doesn't return anything, it does its own printing. It evaluates first, since PHP can't concatenate an expression of which it doesn't know the value. You probably want:
echo "<br><br>testArray is ==> ";
var_dump($testArray);
echo " <===<br><br>";
instead. Print the start, the middle, then the end.