- defined: documentation ( source)
<?php
if(defined("WHATEVER_THIS_ISNT_DEFINED")){ // double quotes needed!
echo 'yup, constant defined';
}
else
{
echo 'nope, does not exist';
}
if(defined('WHATEVER_THIS_ISNT_DEFINED')){ // single quotes won't suppress error notice? no, they work!
echo 'yup, constant defined';
}
else
{
echo 'nope, does not exist';
}
if(defined(WHATEVER_THIS_ISNT_DEFINED)){ // no quotes then error notice
echo 'yup, constant defined';
}
else
{
echo 'nope, does not exist';
}