4 ms·
After 15 years of PHP this is the first and only time I’ve ever seen someone actually use the “global” keyword. And to hijack $data, of all the variables you co
by jw1224 3y ago
After 15 years of PHP this is the first and only time I’ve ever seen someone actually use the “global” keyword. And to hijack $data, of all the variables you could choose…
> This library prioritizes development speed and simplicity over everything else, including best practices and standards.
Oh. At least we were warned!
- nolok 3y agoEspecially since it makes zero sense to do that. If you don't care about niceties and want to have a global variable without the absolute php-3 era failure prone jank just use a class static or hell even a function static or whatever. There is no reason whatsoever to use a global variable like that, hasn't been since ... decades now ? And then to name it data on top of it.
- gorm 3y agoYou are right, but for a project like this, with a name like this, it's rather artful and hacky. Nothing wrong in breaking the rules if you know what you are doing.
- dns_snek 3y agoWhat's the significance of $data in PHP?
- hennell 3y agoNothing special, just it's hardly a rare name for a variable. And this sets it globally.
- manbitesdog 3y ago...inside a namespace called Oink
- jw1224 3y agoFrom the docs: > Although any valid PHP code can be contained within a namespace, only four types of code are affected by namespaces: classes, interfaces, functions and constants.
- onli 3y agoWordPress is the most relevant of all php projects and uses global. In 15 years I would have expected a php developer to at least have a look into the code base of the biggest project of that language...