我试图动态创建一个常量名称,然后获取该值.
define( CONSTANT_1 , "Some value" ) ;
// try to use it dynamically ...
$constant_number = 1 ;
$constant_name = ("CONSTANT_" . $constant_number) ;
// try to assign the constant value to a variable...
$constant_value = $constant_name;
Run Code Online (Sandbox Code Playgroud)
但是我发现$ constant值仍然包含常量的NAME,而不是VALUE.
我也尝试了第二级间接$$constant_name但是这会使它变量而不是常量.
有人可以对此有所了解吗?