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

后端 未结 5 2117
清歌不尽
清歌不尽 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:39

    There are reflection methods that also allow you to construct method and attribute names that may be built by variables or contain special characters. You can use the ReflectionClass::getProperty ( string $name ) method.

    $object->getProperty('variable$WithDollar');

提交回复
热议问题