[英]PHP - Define a constant and use it in a variable name
please can you help me in this problem? 请您能帮我解决这个问题吗?
If in PHP I have a defined constant, can I use that constant name within a variable name? 如果在PHP中我有一个定义的常量,可以在变量名中使用该常量名吗? For example how can I do something like the following in valid php syntax?
例如,如何在有效的php语法中执行以下操作?
define ("HELLO", "hello-you");
$var_HELLO = "something";
echo $var_HELLO;
where HELLO in the variable name is the defined constant. 其中变量名中的HELLO是定义的常量。
many thanks. 非常感谢。
If you absolutely have to do this, 如果您绝对必须这样做,
define ("HELLO", "hello-you");
$var_{HELLO} = "something";
echo $var_{HELLO};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.