PHP static variables in double quotes

后端 未结 9 1574
礼貌的吻别
礼貌的吻别 2020-11-29 08:16

How can I get PHP to evaluate a static variable in double quotes?

I want to do something like this:

log("self::$CLASS $METHOD entering");
         


        
9条回答
  •  青春惊慌失措
    2020-11-29 08:52

    Unfortunately there is no way how to do this yet. Example in one of answers here will not work, because {${self::$CLASS}} will not returns content of self::$CLASS, but will returns content of variable with name in self::$CLASS.

    Here is an example, which does not returns myvar, but aaa:

    $myvar = 'aaa';
    self::$CLASS = 'myvar';
    echo "{${self::$CLASS}}";
    

提交回复
热议问题