PHP » Miscellaneous » defined()

Syntax:
bool defined(string name)
name
Name of the constant to test for.

Returns whether a constant has been defined.

Defined is used to test whether a constant exists. It returns TRUE if a constant with the specified name has been defined, and FALSE otherwise.

Examples

Code:
<?php

define("CONSTANT_A", 1234, FALSE);

if (defined("CONSTANT_A")) {
   print "CONSTANT_A exists<br>";
}

if (!defined("CONSTANT_B")) {
   print "CONSTANT_B does not exist";
}

?>
Output:
CONSTANT_A exists
CONSTANT_B does not exist
Explanation:

The existence of two different constants are tested.

See Also: