News for hackers. Stuff that matters.
Re: by jw1224 on Wednesday February 14, 2024 @04:12AM (#39368036)
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!

Re: by nolok on Wednesday February 14, 2024 @05:24AM (#39368356)
Especially 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.
Re: by gorm on Wednesday February 14, 2024 @09:32AM (#39370174)
You 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.
Re: by dns_snek on Wednesday February 14, 2024 @06:45AM (#39368760)
What's the significance of $data in PHP?
Re: by hennell on Wednesday February 14, 2024 @07:12AM (#39368952)
Nothing special, just it's hardly a rare name for a variable. And this sets it globally.
Re: by juancroldan on Wednesday February 14, 2024 @01:20PM (#39373189)
...inside a namespace called Oink
Re: by jw1224 on Wednesday February 14, 2024 @03:03PM (#39374515)
From 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.

Re: by onli on Wednesday February 14, 2024 @06:49AM (#39368805)
WordPress 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...