Re: Question about `global` variable declaration
| From: | Dan Ackroyd | Date: | Sat, 21 Sep 2019 10:23:15 +0000 |
| Subject: | Re: Question about `global` variable declaration | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107275@lists.php.net to get a copy of this message | ||
Hi Kosit,
On Sat, 21 Sep 2019 at 10:56, Kosit Supanyo <webdevxp.com@gmail.com> wrote:
>
> global $$x;
> global $$$y;
> global $$$$z;
> global ${'abc'};
> global $$$$$$$$$${random_int(0, PHP_INT_MAX)};
I have found the form
global ${'abc'}; useful in the past to work
around the limits on what PHP can parse as variable names, to allow
naming global settings to match how I like to write them in config
files e.g. 'image.upload.retry_attempts'. I would be very surprised if
there was no codebase in existence that didn't use the other forms,
for better or worse.
> If not, should this be changed to ...
For changes like this, the conversation almost certainly needs to
start by stating a clear problem something is causing, and then lead
on to why doing a suggested solution is the right thing to do.
Although this might be a small inconsistency in the language, by
itself, I can't see it causing much harm, except maybe for performance
optimisation as trying to analyze what variables are being used in the
code is hard.
cheers
Dan
Ack