gpt4 book ai didi

PHP - 警告 - 未定义的属性 : stdClass - fix?

转载 作者:IT王子 更新时间:2023-10-29 00:41:40 24 4
gpt4 key购买 nike

我在错误日志中收到此警告,想知道如何在我的代码中更正此问题。

警告:PHP 通知:未定义属性: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() 的功能,但对于对象,什么?还是我做错了?

最佳答案

if(isset($response->records))
print "we've got records!";

关于PHP - 警告 - 未定义的属性 : stdClass - fix?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2471605/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com