How to take a specific value of an object?

Asked

Viewed 197 times

0

I receive this object in PHP (I could see the values with print_r):

stdClass Object ( [id] => 1 ) 1

Wanted to echo only id value (1), how to do?

1 answer

4


As you are receiving an object, you should access it in a similar way to an array. What changes is that instead of $variavel['id'], you use $variavel->id;

In your case, you get the result like this:

echo $objeto->id;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.