PHP static variables in double quotes

Chris picture Chris · Aug 12, 2009 · Viewed 17.7k times · Source

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

Answer

Electro picture Electro · Aug 12, 2009

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