note 35234 rejected from functions.arguments by vincent

From: Date: Sun, 24 Aug 2003 17:03:06 +0000
Subject: note 35234 rejected from functions.arguments by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55001@lists.php.net to get a copy of this message
Note Submitter: Mariusz ---- There is a simply class: class Shop { var $cart; function Shop(&$shop_cart) { $this->cart = $shop_cart; # there is problem } } and variable $shop using "cart_main" session variable: $shop = new Shop ($_SESSION["cart_main"]); Session variable has been initialized. Unfortunatelly it doesn't work, when I use $this->cart = $shop_cart; Everytime when I try to use $this->cart->any_variable there is no previous data. When I change to this: class Shop { var $cart; function Shop(&$shop_cart) { $this->cart = &$shop_cart; # reference } } everything is ok. Why? Passing variable by reference (in Shop function) should solve everything. But it doesn't.

« previous php.notes (#55001) next »