PHP Constant Arrays

PHP 7 新特性PHP 7 New Features

In PHP 5.6, constant arrays could only be defined via const; in PHP 7, they can be defined using define().

Example

<?php
// 使用 define 函数来定义数组
define('sites', [
   'Google',
   'Example',
   'Taobao'
]);

print(sites[1]);
?>

The output of the above program is:

Example

PHP 7 新特性PHP 7 New Features

Other Extensions