PHP static variables in double quotes

2020-01-28 08:55发布

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

7条回答
地球回转人心会变
2楼-- · 2020-01-28 09:52

I don’t know the answer to your question, but you can show the class name and method using the __METHOD__ magic constant.

查看更多
登录 后发表回答