PHP defined()Functions

PHP Misc 参考手册PHP Misc Reference Manual

Examples

Check if a constant exists:

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

Run Example »

Definition and Usage

The defined() function checks whether a constant exists.


Syntax

defined(name)

Parameter Description
name Required. Specifies the name of the constant to check.

Technical Details

Return Value: Returns TRUE if the constant exists, otherwise FALSE.
PHP Version: 4+


PHP Misc 参考手册PHP Misc Reference Manual Other Extensions