PHP defined() 函數

PHP Misc 參考手冊 PHP Misc 參考手冊

實例

檢查某常量是否存在:

<?php
define("GREETING","Hello you! How are you today?");
echo defined("GREETING");
?>


定義和用法

defined() 函數檢查某常量是否存在。


語法

defined(name)

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

技術細節

返回值: 如果常量存在,則返回 TRUE,否則返回 FALSE。
PHP 版本: 4+


PHP Misc 參考手冊 PHP Misc 參考手冊