note 35234 added to functions.arguments

From: Date: Sun, 24 Aug 2003 17:01:27 +0000
Subject: note 35234 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-54999@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35234 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35234&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35234&report=yes

« previous php.notes (#54999) next »