so I acquired a json object from an API and json decoded it…
but then the returned object is of the following:
stdClass Object
(
[id] => stdClass Object
(
[$t] => some string
)
)
And as you can see there is a property with a $ sign in it
but when I do $object->id->$t <–that returns error since it thinks $t is a variable
how would I go about fetching that variable with $ sign?
Encapsulate it as a single-quoted string:
Note that you cannot use double quotes for the same reason you cannot use
$object->id->$t: PHP will attempt to interpolate$t. However, you could use double quotes if you escape the dollar sign:You can see it working in this simple demo.