所以我们可以在PHP5.6中定义数组常量。但是,在类中定义数组常量时,我得到了以下错误
Arrays are not allowed in class constants那么,数组常量是允许的,但不允许在类中使用吗?
发布于 2016-08-11 23:27:21
从PHP 5.6开始,允许在类常量中使用数组。
请参阅link以获取有效的php代码。
<?php
class Foo
{
const BAR = [1,2,3];
}
print_r(Foo::BAR);https://stackoverflow.com/questions/38900385
复制相似问题