Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

defined

Description

The defined of Miscellaneous for PHP checks whether a given named constant exists.

Syntax

defined(
    string $constant_name
): bool

Parameters

constant_name

The constant name.

Return

Returns true if the named constant given by constant_name has been defined, false otherwise.

Examples

1 · constant_name · false

<?

$constant_name = "MYCONSTANT";

$return = defined($constant_name);

var_export($return);

?>
false

2 · constant_name · true

<?

$constant_name = "MYCONSTANT";
$value = "string";

define($constant_name, $value);

$return = defined($constant_name);

var_export($return);

?>
true
HomeMenu