对对象使用会话变量 [英] Using session variable with objects
本文介绍了对对象使用会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个对象并赋值如下:
I have created an object and assigned values as follows:
$car_object =&new Car();
$car_object =& new Car();
$car_object->offer = 'Sale';
$car_object->type = 'Sport Car';
$car_object->location = "Buffalo, New york";
如何将 $car_object 存储在会话变量中?如何从会话变量中取出 $car_object?
How can I store the $car_object inside a session variable? How can I get the $car_object out from the session variable?
推荐答案
设为会话:
$car_object = new Car();
$car_object->offer = 'Sale';
$car_object->type = 'Sport Car';
$car_object->location = "Buffalo, New york";
$_SESSION['car'] = $car_object;
从会话中获取:
$car_object = $_SESSION['car'];
echo $car_object->offer;
这篇关于对对象使用会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文