PHP 7 常量数组
PHP 7 常量数组
现在可以使用define()函数定义数组常量。而在PHP 5.6中,只能使用const关键字定义它们。
例子
<?php
//define a array using define function
define('animals', [
'dog',
'cat',
'bird'
]);
print(animals[1]);
?>上述代码产生如下输出:
cat
现在可以使用define()函数定义数组常量。而在PHP 5.6中,只能使用const关键字定义它们。
<?php
//define a array using define function
define('animals', [
'dog',
'cat',
'bird'
]);
print(animals[1]);
?>上述代码产生如下输出:
cat