Date: 08/15/01
- Next message: jeroen <email protected>: "[PHP-DEV] Bug #12775 Updated: Incorrect result using references and objects"
- Previous message: sniper <email protected>: "[PHP-DEV] Bug #12726 Updated: Make Install Fails"
- Next in thread: jeroen <email protected>: "[PHP-DEV] Bug #12775 Updated: Incorrect result using references and objects"
- Reply: jeroen <email protected>: "[PHP-DEV] Bug #12775 Updated: Incorrect result using references and objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: wayne <email protected>
Operating system: All
PHP version: 4.0.6
PHP Bug Type: Scripting Engine problem
Bug description: Incorrect result using references and objects
If you set a property of an object to a global variable, it is no longer
possible to make a copy of that object! Every "copy" becomes a reference.
Example:
--/ snip /--
class foo
{
function foo()
{
$this->test = 'Test';
$GLOBALS['test'] =& $this->test;
}
}
$obj1 = new foo();
$copyOfObj1 = $obj1; // Should be a copy, but is reference
$obj1->test = "changed!";
echo $copyOfObj1->test.'<br>';
--/ snip /--
The result of this code is: "changed!" but it should be "Test".
$copyOfObj1 should be a copy of $obj1, but instead it acts like a
reference.
If you unset $GLOBALS['test'] then it copies as it should.
This is a bug occurs in all versions of PHP4 on all platforms (from what I
can tell).
-- Edit bug report at: http://bugs.php.net/?id=12775&edit=1-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: jeroen <email protected>: "[PHP-DEV] Bug #12775 Updated: Incorrect result using references and objects"
- Previous message: sniper <email protected>: "[PHP-DEV] Bug #12726 Updated: Make Install Fails"
- Next in thread: jeroen <email protected>: "[PHP-DEV] Bug #12775 Updated: Incorrect result using references and objects"
- Reply: jeroen <email protected>: "[PHP-DEV] Bug #12775 Updated: Incorrect result using references and objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

