Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access/escape PHP object member with a $ character in its name?

Tags:

php

I'm decoding some JSON (from the Youtube data API) with json_decode and it gives me an object that looks like this when var_dump()ed:

object(stdClass)[29]
  public 'type' => string 'text' (length=4)
  public '$t' => string 'Miley and Mandy! KCA VIDEO WINNERS' (length=34)

How can I access the $t member?

like image 990
xanadu Avatar asked Oct 17 '25 15:10

xanadu


1 Answers

Try

$member = '$t';
$obj->$member
like image 85
Andrei Serdeliuc ॐ Avatar answered Oct 19 '25 04:10

Andrei Serdeliuc ॐ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!