PHP defined() Function

Definition and Usage

The defined() function checks if a constant exists.

Returns true if the constant exists, otherwise returns false.

Syntax

defined(name)
Parameters Description
name Required. Specifies the name of the constant to check.

Example

<?php
define("GREETING","Hello world!");
echo defined("GREETING");
?>

Output:

1