I read the PHP manual and its wasn't really clear on any differences. I am confused as to what would the point of using this:
echo "Print this {$test} here.";
compared to this be:
echo "Print this $test here.";
In your example, there is no difference. However, it is helpful when the variable expression is more complex, like an array with a string index. For example:
$arr['string'] = 'thing';
echo "Print a {$arr['string']}";
// result: "Print a thing";
echo "Print a $arr['string']";
// result: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With