How do I access a PHP object attribute having a dollar sign?

后端 未结 5 2122
清歌不尽
清歌不尽 2020-11-29 12:17

I have a PHP Object with an attribute having a dollar ($) sign in it.

How do I access the content of this attribute ?

Example :

echo $object-         


        
5条回答
  •  被撕碎了的回忆
    2020-11-29 12:44

    I assume you want to access properties with variable names on the fly. For that, try

    echo $object->{"variable".$yourVariable}
    

提交回复
热议问题