php_异常解决_sessioin

WBOY
Lepaskan: 2016-06-13 13:05:36
asal
972 orang telah melayarinya

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 中存取对象时要序列化? :)

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan