search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

PHP constant array

In PHP 5.6, constant arrays can only be defined through const, and in PHP 7, they can be defined through define().

Example

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

print(sites[1]);
?>

The execution output of the above program is:

php
new file
<?php // 使用 define 函数来定义数组 define('sites', [ 'Google', 'php', 'Taobao' ]); print(sites[1]); ?>
Reset Code
Automatic operation
submit
Preview Clear