|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40737 Variable passing by reference instead of copying.
Submitted: 2007-03-06 06:45 UTC Modified: 2007-03-06 11:34 UTC
From: anter at voliacable dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.2.0 OS: XP Prof SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: anter at voliacable dot com
New email:
PHP Version: OS:


 [2007-03-06 06:45 UTC] anter at voliacable dot com
In the Simple::$var property the reference to a variable instead of a copy is located, depending on many conditions.

If lines 6 and 8 of bug.php to change places the expected result is received.

If to remove a line 7 of bug.php the expected result is received.

If remove a line 1 of bug.php and to place contents of a Simple.php in a bug.php the expected result is received.

Reproduce code:
<file Simple.php>
1 class Simple
2 {
3     protected static $var;
5     public static function setVar($value)
6     {
7         self::$var = $value;
8     }
9 }

<file bug.php>
1 require_once('Simple.php');
3 $var1 = 'value1';
4 $var2 = 'value2';
6 Simple::setVar($var1);
8 class VerySimple extends Simple {}
10 Simple::setVar($var2);
12 print $var1;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-06 10:49 UTC]
Cannot reproduce.
Please make sure you've disabled all zend extensions like Zend Optimizer, eAccelerator, APC, IonCube etc.
 [2007-03-06 11:34 UTC] anter at voliacable dot com
I am sorry, I had version 5.2.0. In version 5.2.1 all works normally.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 16:01:28 2024 UTC