获得在PHP的Session中保存的对象(Object)属性值

获得在PHP的Session中保存的对象(Object)属性值

作者:admin 时间:2007-03-22 分类:PHP 评论:0条 浏览:1691

Print_r出如下的$_SESSION
[coolcode lang=”php”]
Array
(
[SessionInfo] => SessionInfo Object
(
[_props] => Array
(
[userInfo] => UserInfo Object
(
[_username] => zhouliang
[_password] => 44dc8e76733a23f9eae746fee04a7a30
[_id] => 2
[_aboutmyself] => 完美整合Web2.0流行元素,更易用,更时尚!
[_email] => 033033@gmail.com
[_blogs] =>
[_siteAdmin] => 0
[_fullName] => 周亮
[_resourcePictureId] => 5
[_resourcePicture] =>
[_status] => 1
[_isCommend] =>
[_properties] =>
[_objId] =>
[log] =>
)

)

[_objId] =>
[log] =>
)

)
[/COOLCODE]
我们想获得其中userInfo对象的属性_username的值”zhouliang”,用如下写法:
[COOLCODE lang=”php”]
$name = $_SESSION[SessionInfo]->_props[userInfo]->_username;
echo $name;
[/COOLCODE]
输出:
[COOLCODE lang=”php”]
zhouliang
[/COOLCODE]

原创文章,转载请注明: 转载自www.webmaster.me

本文链接地址: 获得在PHP的Session中保存的对象(Object)属性值

标签:

相关推荐
更多

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*