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.