ala*_*and 6 php const curly-braces
I was surprised to see that the following doesn't work as expected.
define('CONST_TEST','Some string');
echo "What is the value of {CONST_TEST} going to be?";
Run Code Online (Sandbox Code Playgroud)
outputs: What is the value of {CONST_TEST} going to be?
Is there a way to resolve constants within curly braces?
Yes, I am aware I could just do
echo "What is the value of ".CONST_TEST." going to be?";
Run Code Online (Sandbox Code Playgroud)
but I'd prefer not to concatanate strings, not so much for performance but for readability.
不,这是不可能的,因为php将被认为CONST_TEST只是单引号/双引号内的一个字符串。您将必须使用串联。
echo "What is the value of ".CONST_TEST." going to be?";
Run Code Online (Sandbox Code Playgroud)