在PHP中无法访问对象变量

时间:2013-05-05 13:30:47

标签: php object stdclass

出于某种原因,当我print_r包含对象的变量时,我得到了数据。但是,当我尝试使用->表示法访问每个项目时,它表示NULL

以下是print_r的{​​{1}}转储:

$user_data

然而,当我尝试这个时,我得到STDCLASS OBJECT ( [UACC_ID] => 6 [UACC_GROUP_FK] => 1 [UACC_EMAIL] => xxx@GMAIL.COM [UACC_USERNAME] => xxxx [UACC_PASSWORD] => $2A$08$CLSxxxxxxEOS7D2NDCSDD3P6A6 [UACC_IP_ADDRESS] => xx.xxx.xx.65 [UACC_SALT] => C64JYWY7ZS [UACC_ACTIVATION_TOKEN] => [UACC_FORGOTTEN_PASSWORD_TOKEN] => [UACC_FORGOTTEN_PASSWORD_EXPIRE] => 0000-00-00 00:00:00 [UACC_UPDATE_EMAIL_TOKEN] => [UACC_UPDATE_EMAIL] => [UACC_ACTIVE] => 1 [UACC_SUSPEND] => 0 [UACC_FAIL_LOGIN_ATTEMPTS] => 0 [UACC_FAIL_LOGIN_IP_ADDRESS] => [UACC_DATE_FAIL_LOGIN_BAN] => 0000-00-00 00:00:00 [UACC_DATE_LAST_LOGIN] => 2013-05-05 07:18:34 [UACC_DATE_ADDED] => 2013-04-28 09:34:39 [UGRP_ID] => 1 [UGRP_NAME] => PUBLIC [UGRP_DESC] => PUBLIC USER : HAS NO ADMIN ACCESS RIGHTS. [UGRP_ADMIN] => 0 [UPRO_ID] => 6 [UPRO_UACC_FK] => 6 [UPRO_COMPANY] => [UPRO_FIRST_NAME] => xxxx [UPRO_LAST_NAME] => xxxxx [UPRO_PHONE] => 01392 [UPRO_NEWSLETTER] => 0 [UADD_ID] => [UADD_UACC_FK] => [UADD_ALIAS] => [UADD_RECIPIENT] => [UADD_PHONE] => [UADD_COMPANY] => [UADD_ADDRESS_01] => [UADD_ADDRESS_02] => [UADD_CITY] => [UADD_COUNTY] => [UADD_POST_CODE] => [UADD_COUNTRY] => )

NULL

我似乎无法用符号var_dump($user_data->UACC_ID); 等回应任何事情。我做错了什么?

谢谢大家。看来输出在CSS中被转换为ALLCAPS,所以我没有意识到该库实际上使用了小写变体。

感谢。


1 个答案:

答案 0 :(得分:0)

有一种可能性,不管多么奇怪,该对象有一个__get函数被定义为捕获并在内部私有数据点上返回null,以防止php在尝试直接访问任何数据时抛出致命的“无法访问私有”错误。 / p>

所以,是的,UACC_ID存在,并且在那里,但正在被截获。