不,这是不可能的.从手册:
Constants Syntax
原文链接:https://www.f2er.com/php/134919.htmlOnly scalar data (boolean,integer,float and string) can be contained in constants. It is possible to define constants as a resource,but it should be avoided,as it can cause unexpected results.
如果需要设置一组已定义的常量,请考虑创建一个类并使用class constants填充它.手册中略有修改的示例:
class MyClass { const constant1 = 'constant value'; const constant2 = 'constant value'; const constant3 = 'constant value'; function showConstant1() { echo self::constant1 . "\n"; } } echo MyClass::constant3;