#31245 [Opn]: Assigning reference to self results in &$GLOBALS
| From: | rhm31 at cam dot ac dot uk | Date: | Wed, 22 Dec 2004 14:41:03 +0000 |
| Subject: | #31245 [Opn]: Assigning reference to self results in &$GLOBALS | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-70908@lists.php.net to get a copy of this message | ||
ID: 31245
User updated by: rhm31 at cam dot ac dot uk
Reported By: rhm31 at cam dot ac dot uk
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: FreeBSD
PHP Version: 4.3.9
New Comment:
In the example code, the first $obj=&new A; is not needed, sorry.
Previous Comments:
------------------------------------------------------------------------
[2004-12-22 15:39:24] rhm31 at cam dot ac dot uk
Description:
------------
Assigning an global object to be a reference of itself causes the
object to point to $GLOBALS, but only when read from $GLOBALS.
This shows up as the *RECURSION* in the acutal result below.
Note also that Win32 works fine but FreeBSD gives this problem.
Reproduce code:
---------------
<?php
class A
{
}
$obj=&new A;
function &GetA()
{
global $obj;
return $obj;
}
$obj=&new A;
$obj=&GetA();
echo("<PRE>");
var_dump($obj);
print_r($GLOBALS);
echo("</PRE>");
?>
Expected result:
----------------
object(a)(0) {
}
Array
(
...
[GLOBALS] => Array
*RECURSION*
[obj] => a Object
(
)
)
//Note this result is obtained in PHP 4.3.9 on Win32
Actual result:
--------------
object(a)(0) {
}
Array
(
...
[GLOBALS] => Array
*RECURSION*
[obj] => Array
*RECURSION*
)
//Note this result is obtained in PHP 4.3.9 on FreeBSD
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31245&edit=1