I have a little problem with a dynamic constant name declaration.
I can’t find out why the expression defining $constName is not correctly evaluated:
Here is my code:
$type2 = "type2";
$env = "env";
$constName = "test_$type2_$env";
return constant(__CLASS__."::$constName");
After that, I don’t get the correct value : test_type2_env, but this instead: test_env
Thanks in advance.
Try
Because PHP understands that you want the value of the ‘type2_’ variable.