TUTORIAL后端与 Web 服务FETCHED
PHP constant() 函数
PHP constant() 函数 PHP Misc 参考手册 实例 返回一个常量的值: <?php//define a constant define('GREETING','Hello you! How are you today?'); echo constant('GREETING'); ?> 运行实例 » 定义和用法 cons..
更新于 2026/7/16
教程详情页默认 noindex。
PHP constant() 函数
实例
返回一个常量的值:
<?php
//define a constant
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>
//define a constant
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>
运行实例 »
定义和用法
constant() 函数返回一个常量的值。
注释: 该函数也适用于 class 常量。
语法
constant(constant)
| 参数 | 描述 |
|---|---|
| constant | 必需。规定要检查的常量的名称。 |
技术细节
| 返回值: | 返回常量的值,如果常量未定义则返回 NULL。 |
|---|---|
| PHP 版本: | 4+ |
PHP Misc 参考手册