我使用的库使用数组。将 print_r 应用于该数组会打印:
Array
(
[*queueId] => 1
[*handle] => 9b875867b36d568483fb35fdb8b0bbf6
[*body] => First string in the TestQueue
[*md5] => c23ba714199666efbc1dcd5659bb0a0a
[*timeout] => 1408003330.6534
[*id] => 2
[*creationdate] => 2014-08-13 16:03:37
)
该库在该数组上使用了一个魔法吸气剂
public function __get($key)
{
if (!array_key_exists($key, $this->_data)) {
throw new Exception\InvalidArgumentException("Specified field \"$key\" is not in the message");
}
return $this->_data[$key];
}
当我尝试访问
$myObject->body
我遇到了异常。事实上,调试器显示 array_key_exists 将返回 false 而 _data 数组可用,如上所示