现在可以使用 define()函数定义数组常量。在PHP 5.6中,只能使用 const 关键字定义它们。
<?php //define a array using define function define('animals', [ 'dog', 'cat', 'bird' ]); print(animals[1]); ?>
它产生以下浏览器输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/php7+/php7-constant-arrays.html
来源:LearnFk无涯教程网
cat
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)