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 中存取对象时要序列化? :)
相关文章
相关视频
推荐阅读
-
discuzX中出现mysql链接异常2003,PHP-fpm 502异常的另类解决办
-
Linux tomcat连接Window MySQL异常的解决
-
Oracle DMP文件异常解决
-
discuzX中出现mysql链接异常2003,PHP-fpm 502异常的另类解决办
-
多个jquery.datatable共存,checkbox全选异常的快速解决方法_javascript技巧
-
phpStudey2010中进入phpMyAdmin出现"无法在发生异常时创建会话,请检查PHP"的解决办法
-
解决python3捕获cx_oracle抛出的异常错误问题
-
php中“Deprecated: Function split() is deprecated in”异常解决方法
-
自行解决12306页面显示异常的问题_html/css_WEB-ITnose
-
JSP 开发SSH整合异常解决办法