简体   繁体   English

PHP访问数组对象

[英]PHP accessing array object

I am using a third party software and the print_r($_SESSION) gives me this我正在使用第三方软件, print_r($_SESSION)给了我这个

[stsco-portal_current_user] => UserIdentity Object
    (
        [userName] => Gary
        [password] => 
        [persistent] => 
    )

I need to access the userName and have tried various combinations of the following我需要访问userName并尝试了以下各种组合

echo $_SESSION['stsco-portal_current_user']->$UserIdentity->['userName'];

keeps giving me an error.一直给我一个错误。

I know i can access it(used it before in another project using a differnt system) i just forgot how to do it.我知道我可以访问它(之前在另一个使用不同系统的项目中使用过它)我只是忘了怎么做。 Any help ?有什么帮助吗?

There's no $UserIdentity variable.没有$UserIdentity变量。 UserIdentity is just the class of the object, you don't need to specify that when accessing it. UserIdentity只是对象的类,访问时不需要指定。 Just specify the property name.只需指定属性名称。

echo $_SESSION['stsco-portal_current_user']->userName;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM