phpvariablesstaticdoublequotes

PHP static properties in double quotes


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");

I've tried all sorts of {} combos to get the variable value of self::$CLASS, but nothing has worked. I've currently settled with string concatenation but it is a pain to type:

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

Solution

  • Sorry, you can't do that. It only works for simple expressions. See here.