从 php 对象获取值

发布于 2024-09-24 02:09:22 字数 362 浏览 1 评论 0原文

我在代码中的一个对象上使用了 var_dump 。 print var_dump( $$user);

结果:object(stdClass)#35 (1) { ["user1_ready"]=>; string(1) "0" } 我如何获得这个值(在本例中为 0)。

我尝试打印 $$user ,导致 Catchable fatal error: Object of class stdClass Could not be Converted to string in

我需要类似 if($$user == 0){echo "错误消息”) else {

I used var_dump on an object in my code. print var_dump( $$user);

result: object(stdClass)#35 (1) { ["user1_ready"]=> string(1) "0" } How do I get to this value (0 in this case).

I tried print $$user which resulted in Catchable fatal error: Object of class stdClass could not be converted to string in

I need something like if($$user == 0){echo "error message") else {

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

站稳脚跟 2024-10-01 02:09:22

您需要使用属性/方法访问器“->”。它通常如下:

$object->method()$object->property

所以你的将是

$$user->user1_ready >

You need to use the property/method accessor "->". It generally follows:

$object->method() or $object->property

so yours would be

$$user->user1_ready

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文