Re: global variables in php4 code

From: Date: Mon, 08 Oct 2007 14:17:53 +0000
Subject: Re: global variables in php4 code
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48240@lists.php.net to get a copy of this message
According to the PHP docs [1]: "Notice how $GLOBALS exists in any scope, this is because $GLOBALS is a superglobal." As I understand it there is no need to do a "global $GLOBALS". This is just a note. I understood the context of your question... The manual only points that specific problem with the use of "global" : ##### The Zend Engine 1, driving PHP 4, implements the static and global modifier for variables in terms of references. For example, a true global variable imported inside a function scope with the global statement actually creates a reference to the global variable. This can lead to unexpected behaviour which the following example addresses: <?php function test_global_ref() { global $obj; $obj = &new stdclass; } function test_global_noref() { global $obj; $obj = new stdclass; } test_global_ref(); var_dump($obj); test_global_noref(); var_dump($obj); ?> Executing this example will result in the following output: NULL object(stdClass)(0) { } ##### regards, iGor. [1] http://br.php.net/global

« previous php.pear.dev (#48240) next »