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