Hacker News new | ask | show | jobs
by andreareina 1458 days ago
I still don't know how I feel about the fact that in PHP $$var (a) works, and (b) does exactly what you'd expect.
2 comments

Early days of PHP were total madness. GET vars initialized variables in the global namespace. Uninitialized variables treated as zero/empty string. People were rolling their own query sanitizers in the best case. Misconfigured servers often horked out script sources. Why not pour some gas on it with variable variables?
This level of introspection can be useful in some cases. Perhaps the flaw is just in giving it such simple, attractive syntax.
I think so. You can get at the __globals__ dict in python to similar effect, and I've rarely seen that abused.