php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20670 Object reference with global variables bug
Submitted: 2002-11-27 03:36 UTC Modified: 2002-12-09 06:37 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sitnikov at infonet dot ee Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.3.0-dev OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sitnikov at infonet dot ee
New email:
PHP Version: OS:

 

 [2002-11-27 03:36 UTC] sitnikov at infonet dot ee
$globalref_bar===NULL  after  $o2 = &new Bar();

Source
----------------------------
<?
    $globalref_foo = array();
    $globalref_bar = null;

        class Foo {
                function Foo()
                {
                        global $globalref_foo;
                        $globalref_foo[] = &$this;
                }
        }

        class Bar {
                function Bar()
                {
                        global $globalref_bar;
                        $globalref_bar = &$this;
                }
        }

        $o1 = &new Foo();
        $o2 = &new Bar();

        var_dump($globalref_foo);
        var_dump($globalref_bar);
        var_dump($o1);
        var_dump($o2);
?>

Output:
----------------------------
array(1) {
  [0]=>
  &object(foo)(0) {
  }
}
NULL
object(foo)(0) {
}
object(bar)(0) {
}
-----------------------------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-09 06:37 UTC] andi@php.net
Will be fixed in Engine 2.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 19:01:37 2025 UTC