PHP constant() 函數

定義和用法

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

語法

constant(constant)
參數 描述
constant 必需。規定要檢查的常量的名稱。

提示和注釋

注釋:該函數僅適用于 class 常量。

實例

<?php
//定義一個常量
define("GREETING","Hello world!");
echo constant("GREETING");
?>

輸出:

Hello world!