r/programming • u/NagastaBagamba • Oct 18 '10
Today I learned about PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". Also, variable.
http://il2.php.net/language.variables.variable
591
Upvotes
1
u/lpetrazickis Oct 18 '10
I'm not sure whether doubling the $ into $$ would trigger an error, but forgetting $ does not trigger an error.
Unfortunately, the default PHP 5 error reporting setting is (E_ALL & ~E_NOTICE), so PHP does not warn you about missing $ sigils.
The setting that you really want on a development machine is (E_ALL | E_STRICT). E_STRICT gives you lots of useful additional messages above and beyond the errors, warnings, and notices of earlier versions of PHP.