PHP defined() Function
Example
Check if a constant exists:
<?php
define("GREETING","Hello you! How are you today?");
echo defined("GREETING");
?>
Try it Yourself »
Definition and Usage
The defined() function checks whether a constant exists.
Syntax
defined(name)
Parameter Values
Parameter | Description |
---|---|
name | Required. Specifies the name of the constant to check |
Technical Details
Return Value: | Returns TRUE if the constant exists, or FALSE otherwise |
---|---|
PHP Version: | 4+ |
❮ PHP Misc Reference