【发布时间】:2014-01-07 10:12:17
【问题描述】:
如何使用冒号 ":protected" 访问 stdClass 的值?
例如,我有这个 $obj 有以下结果:
object(Google_Service_Plus_PeopleFeed)#14 (11) {
["title"]=>
string(30) "Google+ List of Visible People"
["totalItems"]=>
int(4)
["collection_key:protected"]=>
string(5) "items"
["data:protected"]=>
array(1) {
["items"]=>
array(2) {
[0]=>
array(7) {
["kind"]=>
string(11) "plus#person"
["etag"]=>
string(57) ""42gOj_aEQqJGtTB3WnOUT5yUTkI/1eNkvlfeTwXXldr9rYAvMcwM6bk""
["objectType"]=>
string(6) "person"
例如,我尝试使用以下代码访问“kind”值,即“plus#person”:
$kind = $obj->{'data:protected'}->items[0]->kind; //-> returns NULL
//OR
$kind = $obj->{data:protected}->items[0]->kind; //->returns error on ":"
好吧,它们似乎不起作用...知道如何访问受保护的数据吗?
谢谢
【问题讨论】:
-
没有访问器吗?