双引号中的 PHP 静态变量 [英] PHP static variables in double quotes
本文介绍了双引号中的 PHP 静态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让 PHP 用双引号计算静态变量?
How can I get PHP to evaluate a static variable in double quotes?
我想做这样的事情:
log("self::$CLASS $METHOD entering");
我尝试了各种 {}
组合来获取 self::$CLASS
的变量值,但没有任何效果.我目前已经解决了字符串连接问题,但输入起来很痛苦:
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");
推荐答案
抱歉,您不能这样做.它只适用于简单的表达式.请参阅此处.
Sorry, you can't do that. It only works for simple expressions. See here.
这篇关于双引号中的 PHP 静态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文