Re: Re: referencing Superglobals with variable variables inside functions

From: Date: Fri, 04 Feb 2005 02:06:48 +0000
Subject: Re: 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-14632@lists.php.net to get a copy of this message
Superglobals are compiled into global fetches. However, we didn't want to and don't want to slow down the average fetch by checking if it's a superglobal first (i.e. variable variable). This also includes $this which is evaluted at compile-time. I think this is quite fair. Andi At 11:12 PM 2/3/2005 +0100, Michael Virnstein wrote:
Sara Golemon wrote: Index: Zend/zend_execute.c =================================================================== RCS file: /repository/ZendEngine2/zend_execute.c,v retrieving revision 1.692 diff -u -r1.692 zend_execute.c
--- Zend/zend_execute.c 22 Jan 2005 02:29:18 -0000      1.692
+++ Zend/zend_execute.c 31 Jan 2005 22:13:50 -0000 @@ -1001,6 +1001,10 @@ {
        switch (opline->op2.u.EA.type) {
                case ZEND_FETCH_LOCAL:
+                       if (zend_hash_exists(CG(auto_globals),
variable->value.str.val, variable->value.str.len + 1)) {
+                               /* Dynamically resolved auto global */
+                               return &EG(symbol_table);
+                       }
                        return EG(active_symbol_table);
                        break;
                case ZEND_FETCH_GLOBAL:
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? Michael -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#14632) next »