PHP - 警告 - 未定义的属性: stdClass - 修复?
我在错误日志中收到此警告,并想知道如何在我的代码中更正此问题。
警告:PHP 注意:未定义的属性:stdClass::脚本中的$records.php第 440 行
一些代码:
// Parse object to get account id's
// The response doesn't have the records attribute sometimes.
$role_arr = getRole($response->records); // Line 440
记录存在时的响应
stdClass Object
(
[done] => 1
[queryLocator] =>
[records] => Array
(
[0] => stdClass Object
(
[type] => User
[Id] =>
[any] => stdClass Object
(
[type] => My Role
[Id] =>
[any] => <sf:Name>My Name</sf:Name>
)
)
)
[size] => 1
)
记录不存在时的响应
stdClass Object
(
[done] => 1
[queryLocator] =>
[size] => 0
)
我在想像array_key_exists()功能这样的东西,但对于对象,什么?还是我以错误的方式去做了?