PHP constant()Functions
Examples
Returns the value of a constant:
<?php
//define a constant
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>
//define a constant
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>
Run example »
Definition and Usage
The constant() function returns the value of a constant.
Note:This function also works for class constants.
Syntax
constant(constant)
| Parameter | Description |
|---|---|
| constant | Required. Specifies the name of the constant to check. |
Technical Details
| Return value: | Returns the value of the constant, or NULL if the constant is not defined. |
|---|---|
| PHP Version: | 4+ |
PHP Misc Reference Manual Other Extensions