Home >Backend Development >PHP Tutorial > 一个对象能否放入数组解决办法

一个对象能否放入数组解决办法

WBOY
WBOYOriginal
2016-06-13 12:55:18733browse

一个对象能否放入数组
有一个类的静态方法返回一个对象使用print_r打印如:
User Object ( [UserID:private] => 1829 [UserInfoArr:private] => Array ( [UserName] => dong [UserPasswd] => 9d10b7eae72c5f1bb0b4fc1a68a34032   [Description] => ab [IsAuthEmail] => 0 [IsDelete] => 0 ) )
现在我要取出对象中数组的UserName,但是都不能成功;要怎么读取对象中数组的value?还是对象不能有数组,这种方法(对象中有数组)是错误的?


------解决方案--------------------
你需要先让UserInfoArr属性变为共有public,而不是禁止外部访问的private属性。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn