Weird problem with objects
| From: | Mark Cubitt | Date: | Fri, 23 Jan 2004 10:35:28 +0000 |
| Subject: | Weird problem with objects | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-175499@lists.php.net to get a copy of this message | ||
hi,
I have a shopping cart I'm having probs with.
I have a cart class that starts like this:
<CODE>
require_once("class_database.php"); // Database Class
require_once("class_accessory.php"); // Accessory Class
require_once("class_order.php"); // Order Class
class cart
{
var $database;
var $accessory;
var $order;
function cart() {
$this->$database = new database();
$this->$accessory = new accessory();
$this->$order = new order();
} // end function cart
</CODE>
and has a line like this:
<CODE>
$price = $this->$accessory->get_accessoryPrice("$key");
</CODE>
there is a get_accessoryPrice function in the accessory class,
but it won't work unless I use this line instead:
<CODE>
$price = $this->$$this->$accessory->get_accessoryPrice("$key");
</CODE>
This makes no sense to me what so ever, so can anybody shed some light on it
for me.
I'm prob just making a silly mistake but any help would be very much
appreciated.
Thanks in advance
Regards
Mark Cubitt