首页 > 编程教程 > PHP7 教程
2016
09-20

PHP7常量数组

数组常量现在可以使用 define() 函数定义。 在PHP5.6,它们只能使用 const 关键字定义。

示例

<?php
   //define a array using define function
   define('animals', [
      'dog',
      'cat',
      'bird'
   ]);
   print(animals[1]);
?>
这将在浏览器产生输出以下结果 - 
cat

关注编程技巧 回复19领350本编程书籍

编程技巧