Possible Duplicate:
curly braces in string
Just came across this piece of code and it got me curious…
$msg .= "–{$mime_boundary}–n";
The $mime_boundary var was specified earlier to be output as a string.
Did a quick test….
$var = "XmytextX";
$str ="some wrapper{$var}end of";
echo $str;
and it does indeed output into the string. I’ve just never seen this way of outputting a var before.
Couldn’t find any documentation on it – can anyone enlighten me?
So, normally, you could use the double quotes to output any variable like so:
But, what if you wanted to output an item inside an array?
That wouldn’t work. So, you would enclose the variable in curly brackets to tell the compiler to interpolate the entire variable:
On that note, you could also use it with objects:
Hope that helps!