Domanda

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.

È stato utile?

Soluzione

If you absolutely have to do this,

define ("HELLO", "hello-you");
$var_{HELLO} = "something";
echo $var_{HELLO};
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top