PHP 常量數組
在PHP 5.6 中僅能通過const 定義常量數組,PHP 7 可以通過define() 來定義。
實例
<?php // 使用 define 函数来定义数组 define('sites', [ 'Google', 'w3big', 'Taobao' ]); print(sites[1]); ?>
以上程序執行輸出結果為:
w3big
在PHP 5.6 中僅能通過const 定義常量數組,PHP 7 可以通過define() 來定義。
<?php // 使用 define 函数来定义数组 define('sites', [ 'Google', 'w3big', 'Taobao' ]); print(sites[1]); ?>
以上程序執行輸出結果為:
w3big