PHP static variables in double quotes

后端 未结 9 1575
礼貌的吻别
礼貌的吻别 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:45

    I know this is an old question but I find it odd that noone has suggested the [sprintf][1] function yet.

    say:

    you would use it with:

    echo sprintf( '$a value is %s', Foo::$a );
    

    so on your example its:

    log(
        sprintf ( ' %s $METHOD entering', self::$CLASS )
    );
    

提交回复
热议问题