PHP 中的 constant() 函数


constant() 函数返回常量的值。

语法

constant(const)

参数

  • const − 设置要查询的常量的名称

返回

constant() 函数返回一个常量的值,如果常量未定义,则返回 NULL。

示例

以下是定义常量的示例。

 实时演示

<?php
   define("myConstant","This is it!");
   echo constant("myConstant");
?>

输出

以下是输出。

This is it!

更新于:27-6-2020

199 次浏览

开启您的 职业

完成课程即可获得认证

开始上手
广告
© . All rights reserved.