开发者

Getting a value from an object php

开发者 https://www.devze.com 2023-01-16 15:11 出处:网络
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 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 stdCla开发者_运维知识库ss could not be converted to string in

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


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

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

so yours would be

$$user->user1_ready

0

精彩评论

暂无评论...
验证码 换一张
取 消