PHP数组问题和500错误

PHP数组问题和500错误,php,Php,因此,在我的代码中,我有: var_dump($poll); 其中打印: object(stdClass)#2 (9) { ["parent"]=> object(stdClass)#3 (3) { ["className"]=> string(5) "Venue" ["__type"]=> string(7) "Pointer" ["objectId"]=> string(10) "HRSCYpe2FK"

因此,在我的代码中,我有:

 var_dump($poll);
其中打印:

object(stdClass)#2 (9) {
    ["parent"]=> object(stdClass)#3 (3) {
        ["className"]=> string(5) "Venue"
        ["__type"]=> string(7) "Pointer"
        ["objectId"]=> string(10) "HRSCYpe2FK"
    }
    ["no"]=> int(0)
    ["updatedAt"]=> string(24) "2011-11-06T23:37:17.917Z"
    ["creator"]=> object(stdClass)#4 (3) {
        ["className"]=> string(5) "_User"
        ["__type"]=> string(7) "Pointer"
        ["objectId"]=> string(10) "96K81tdpM4"
    }
    ["createdAt"]=> string(24) "2011-11-06T23:37:14.591Z"
    ["yes"]=> int(1)
    ["objectId"]=> string(10) "U8ly32582W"
    ["question"]=> string(20) "Negozio conveniente?"
    ["reports"]=> object(stdClass)#5 (0) { }
} 
然后我想做:

var_dump($poll["parent"]["objectId"]);
但是它给了我一个500的内部服务器错误。知道为什么吗

更新: 从错误日志中提取,它显示:

PHP致命错误:无法将stdClass类型的对象用作数组


看起来您的
$poll
变量是一个
stdclass
,在这种情况下,您可以这样访问属性

var_dump($poll->parent->objectId)

至于您的500状态,我猜PHP配置为触发此错误。

看起来您的
$poll
变量是一个
stdclass
,在这种情况下,您可以这样访问属性

var_dump($poll->parent->objectId)

至于您的500状态,我猜PHP配置为触发此错误。

这是因为您要在对象而不是数组上执行var_转储

$poll->parent->objectId


object::object::property

这是因为您要在对象而不是数组上执行var_转储

$poll->parent->objectId

对象::对象::属性