PHP中的静态变量为双引号 [英] PHP static variables in double quotes
本文介绍了PHP中的静态变量为双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ p
$ b
我想要这样做:
log(self :: $ CLASS $ METHOD enter);
我尝试过各种{}组合来获取self :: $ CLASS的变量值,但没有任何工作。我现在已经用字符串连接进行了定位,但是输入以下内容是一个困难:
log(self :: $ CLASS。方法输入);
解决方案
对不起,你不能这样做。它只适用于简单表达式。请参阅此处。
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");
解决方案
Sorry, you can't do that. It only works for simple expressions. See here.
这篇关于PHP中的静态变量为双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文