php session购物车问题
<br />class CartTool<br /> {<br /> private static $ins;<br /> private $good = array();<br /> <br /> final private function __construct()<br /> {<br /> <br /> }<br /> final private function __clone()<br /> {<br /> <br /> }<br /> <br /> // 获取实例<br /> protected static function getIns() <br /> {<br /> if(!(self::$ins instanceof self)) <br /> {<br /> self::$ins = new self();<br /> }<br /><br /> return self::$ins;<br /> }<br /> <br /> <br /> /**<br /> * 函数作用:把购物车的单例对象放到session里<br /> * <br /> * <br /> * @return instance 购物车的单例对象<br /> * */<br /> public static function getCart() <br /> {<br /> if(!isset($_SESSION['cart']) || !($_SESSION['cart'] instanceof self)) <br /> {<br /> echo '1';<br /> $_SESSION['cart'] = self::getIns();<br /> }<br /><br /> return $_SESSION['cart'];<br /> }<br /><br />