Skip to content
Advertisement

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";

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement