Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the difference between {$var} and $var?

I would like to know when and why should I use {$var}

echo "This is a test using {$var}";

and when (and why) should I use the simple form $var

echo "This is a test using $var";
like image 817
sica07 Avatar asked Dec 12 '22 12:12

sica07


1 Answers

You would use the latter when a) not accessing an object or array for the value, and b) no characters follow the variable name that could possibly be interpreted as part of it.

like image 127
Ignacio Vazquez-Abrams Avatar answered Jan 01 '23 09:01

Ignacio Vazquez-Abrams