我在错误日志中看到了这个警告,想知道如何在我的代码中解决这个问题。
警告: PHP Notice: Undefined property: stdClass::$records in script.php on line 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()的对象功能,有没有这样的东西?或者我的思路错了?