在 PHP 5.6 中仅能通过 const 定义常量数组,PHP 7 可以通过 define() 来定义。
实例
// 使用 define 函数来定义数组 define('sites', [ 'Google', 'Runoob', 'Taobao' ]); print(sites[1]);
以上程序执行输出结果为:
51frw
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!
在 PHP 5.6 中仅能通过 const 定义常量数组,PHP 7 可以通过 define() 来定义。
// 使用 define 函数来定义数组 define('sites', [ 'Google', 'Runoob', 'Taobao' ]); print(sites[1]);
以上程序执行输出结果为:
51frw