PHP7常量數組

數組常量現在可以使用 define() 函數定義。 在PHP5.6,它們只能使用 const 關鍵字定義。

示例

<?php
   //define a array using define function
   define('animals', [
      'dog',
      'cat',
      'bird'
   ]);
   print(animals[1]);
?>
這將在流覽器產生輸出以下結果 - 
cat

上一篇: PHP7飛船操作符 下一篇: PHP7匿名類