Re: referencing Superglobals with variable variables inside functions
| From: | Sara Golemon | Date: | Thu, 03 Feb 2005 23:52:23 +0000 |
| Subject: | Re: referencing Superglobals with variable variables inside functions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-14616@lists.php.net to get a copy of this message | ||
> i must admit, that i don't know very much about the zend engine and the
> php core in general, but if "opline->op2.u.EA.type" "knows" if the
> variable is a local one, a global one or a static one, why hasn't it the
> value of ZEND_FETCH_GLOBAL for superglobals in the first place?
>
opline->op2.u.EA.type is set at compile time.
In the case of $_GET, the compiler knows that _GET is a superglobal so it
sets it to ZEND_FETCH_GLOBAL
In the case of $$g (where $g was previously set to '_GET') the compiler
doesn't know what $g is yet (since it's only really set at runtime), so it
has no reason to set it to ZEND_FETCH_GLOBAL.
Could it be intelligent enough to see that in:
$g = '_GET';
$$g is always going to be '_GET' and therefor $$g and $_GET are really the
same thing?
Perhaps.
But what about:
$g = '_';
$g .= 'G';
$g .= 'E';
$g .= 'T';
Or the enigmatic:
$g = '_TRG';
$g = str_rot13($g);
Building the run-time intelligence into a compiler would be.... well do I
really need to spell that one out?
-Sara