PHP 4.0 Bug #9479 Updated: new operator behaves in a really strange way
| From: | stas@php.net | Date: | Thu, 08 Mar 2001 11:48:05 +0000 |
| Subject: | PHP 4.0 Bug #9479 Updated: new operator behaves in a really strange way | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-48232@lists.php.net to get a copy of this message | ||
ID: 9479
Updated by: stas
Reported By: passionplay@hotmail.com
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Assigned To:
Comments:
Yes, when you do a $obj = new Foo(), the object is copied.
Use =& if you want reference.
Previous Comments:
---------------------------------------------------------------------------
[2001-02-27 09:16:56] passionplay@hotmail.com
$objectlist=array();
class MyClass
{
function MyClass()
{
global $objectlist;
// Save the reference for later use
$objectList[]=&$this;
}
};
// the object referred to by $myobject is NOT in the array
$myobject = new MyClass();
// $myobject2 exists in the array
$myobject2 =& new MyClass();
It appears that there is an object being copied when returning from the constructor. What am I doing
wrong?
I'm not supposed to return anything from the constuctor.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9479&edit=2