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