我在错误日志中收到此警告,并想知道如何在代码中更正此问题。
警告:PHP注意:未定义属性:stdClass :: $ records在440行的script.php中
一些代码:
// 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()的功能,但是对于对象,还有什么吗?还是我走错路了?
if(isset($response->records)) print "we've got records!";