Re: Weird problem with objects

From: Date: Fri, 23 Jan 2004 10:46:19 +0000
Subject: Re: Weird problem with objects
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175500@lists.php.net to get a copy of this message
Mark Cubitt wrote:
$this->$database = new database(); $this->$accessory = new accessory(); $this->$order = new order();
These should be... $this->database = new database(); $this->accessory = new accessory(); $this->order = new order(); You don't want the $ unless $database, $accessory and $order are strings containing the class attribute names. Additionally, you might want to assign the reference of the new objects otherwise PHP will create a new object and then make a copy of it - not very efficient. Like so... $this->database = & new database(); $this->accessory = & new accessory(); $this->order = & new order(); -- Stuart

« previous php.general (#175500) next »