PHP如何动态调用define
我想做一个连接来调用我的define,但php不想 举例来说:PHP如何动态调用define,php,string,dynamic,concatenation,Php,String,Dynamic,Concatenation,我想做一个连接来调用我的define,但php不想 举例来说: define('FOO_1', 'string 1'); define('FOO_2', 'string 2'); 我想动态地调用它: $id = 1; echo FOO_.$id; 但它显示: FOO_1 (不是“字符串1”) 如何使用constant() 见以下文件: 通过使用常量() 见以下文件: 归功于Yent echo constant('FOO_'.$id);
define('FOO_1', 'string 1');
define('FOO_2', 'string 2');
我想动态地调用它:
$id = 1;
echo FOO_.$id;
但它显示:
FOO_1(不是“字符串1”) 如何使用
constant()
见以下文件:
通过使用常量()
见以下文件:
归功于Yent
echo constant('FOO_'.$id);