문제

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? For example how can I do something like the following in valid php syntax?

define ("HELLO", "hello-you");
$var_HELLO = "something";
echo $var_HELLO;

where HELLO in the variable name is the defined constant.

many thanks.

도움이 되었습니까?

해결책

If you absolutely have to do this,

define ("HELLO", "hello-you");
$var_{HELLO} = "something";
echo $var_{HELLO};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top