写购物车时遇到问题,
?
?
fatal error: dangdangservice::addcartitem() [dangdangservice.addcartitem]: the script tried to execute a method or access a property of an incomplete object. please ensure that the class definition cart of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition
?
?
查询发现;
?
$car = null;
if(empty($_session['car'])){
$uid = $_session['uid'];?
$car = dangdangservice::getinstance()->createcart($uid, $bookid);
//php 特性,对象,往session存,序列化
$_session['car'] = serialize($car);
//$_session['car'] = $car;
}else{
? $car = unserialize($_session['car']);
? //$car = $_session['car'];
? $_session['car'] = serialize(dangdangservice::getinstance()->addcartitem($car, $bookid));
? // $_session['car'] = dangdangservice::getinstance()->addcartitem($car, $bookid);
}
$osmarty->assign(items,$car->getitems());
$osmarty->display(car.html);
?
?
?
?
php 在session 中存取对象时要序列化? :)