Getting new object by ref.

From: Date: Thu, 21 Dec 2000 22:05:17 +0000
Subject: Getting new object by ref.
Groups: php.dev 
Request: Send a blank email to php-dev+get-42083@lists.php.net to get a copy of this message
Hi All, $object = &new myTest(); does not work when used inside a function. Changing it to $object = new myTest(); makes the function work. - Frank Sample code: class myTest { var $data; function myTest() { $this->data = "Test"; } function GetData() { return $this->data; } } $object = null; function init() { global $object; $object = &new myTest(); } function write() { global $object; print($object->GetData() . "\n"); } /* main */ init(); write();

« previous php.dev (#42083) next »