PHP5.6 是 CLASS 常量中允许的数组

PHP5.6 are arrays allowed in CLASS constants

所以我们可以在PHP5.6中定义数组常量。但是,在 class

中定义数组常量时出现以下错误
Arrays are not allowed in class constants

所以classes里面允许数组常量是真的吗?

从 PHP 开始,class 常量中允许使用 5.6 个数组。

请参阅 link 以获取有效的 php 代码。

<?php

class Foo 
{
    const BAR = [1,2,3];
}

print_r(Foo::BAR);