How to check if a defined constant exists in PHP?
First, these are not variables, but constants.
And you can check their existence by using the defined()
function :
bool defined ( string $name )
Checks whether the given constant exists and is defined.
Check using defined('CONSTANT')
function.
An example from the manual:
<?php/* Note the use of quotes, this is important. This example is checking * if the string 'TEST' is the name of a constant named TEST */if (defined('TEST')) { echo TEST;}?>