php_异常解决_sessioin
写购物车时遇到问题,
?
?
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 中存取对象时要序列化? :)
相关文章
相关视频
推荐阅读
-
ThinkPHP令牌异常如何解决
-
phpStudey2010中进入phpMyAdmin出现"无法在发生异常时创建会话,请检查PHP"的解决办法
-
php更新mysql后获取影响的行数发生异常解决方法_php技巧
-
Element animation-list must be declared异常解决_html/css_WEB-ITnose
-
如何解决频率很第的代码异常。
-
应用程序发生异常 unknown software exception的解决方法
-
解决spring @ControllerAdvice处理异常无法正确匹配自定义异常
-
电脑开机出现异常提示keyboard not found的故障原因及解决方法
-
解决mysql时区与系统时区不一致问题。异常:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized o
-
使用unset()时出现的异常如何解决