PHP 常量数组 登录

PHP 常量数组

在 PHP 5.6 中仅能通过 const 定义常量数组,PHP 7 可以通过 define() 来定义。

实例

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

print(sites[1]);
?>

以上程序执行输出结果为:

php
下一节
<?php // 使用 define 函数来定义数组 define('sites', [ 'Google', 'php', 'Taobao' ]); print(sites[1]); ?>
提交 重置代码
章节 评论 笔记 课件
  • 取消 回复 发送
  • 取消 发布笔记 发送