>
> Unlike var, public, static and others - 'global' is not a declaration of
> class structure, but a way to access global variables.


I know it is not and I think almost everyone knows that. As I said, I came
up with this by comparing to other declarations syntactically not
functionally, it is inconsistent in that way. I don't know how many PHP
developers out there know `global` can take variable variables but I my
guess is, very very little because there's no information about this
behavior of `global` in PHP manual
https://www.php.net/manual/en/language.variables.scope.php and I'd never
seen those forms of `global` in any projects/articles before.

Cheers

On Sat, Sep 21, 2019 at 9:26 PM Zeev Suraski <z...@php.net> wrote:

> On Sat, Sep 21, 2019 at 3:09 PM Kosit Supanyo <webdevxp....@gmail.com>
> wrote:
>
>> I understand your point but inconsistency in my sense is syntactical By
>> comparing to other declaration syntax like `var`, `static`, 'public` an
>> others. They allow only T_VARIABLE but `global` is different. And there's
>> another way to archive the same goal through `$GLOBALS`, that's why I see
>> it as inconsistency.
>>
>
> Even though we're dealing with archeology here - this really isn't an
> inconsistency but intended behavior.
> Unlike var, public, static and others - 'global' is not a declaration of
> class structure, but a way to access global variables.  In the same way it
> sometimes makes sense to access variables indirectly ($$foo), it may
> sometimes make sense to access global variables indirectly (global $$foo).
> It allows for both creation and access of global variables.  It doesn't
> sound very useful or practical to provide that ability for the creation of
> dynamic class properties, which is why it's not available for
> var/public/static/etc.
>
> Zeev
>

Reply via email to