php.net |  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
 [2007-03-06 06:45 UTC] anter at voliacable dot com
Description:
------------
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;
4 
5     public static function setVar($value)
6     {
7         self::$var = $value;
8     }
9 }

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

Expected result:
----------------
value1


Actual result:
--------------
value2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-06 10:49 UTC] tony2001@php.net
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