note 83352 deleted from function.get-defined-constants by felipe

From: Date: Fri, 23 May 2008 23:46:57 +0000
Subject: note 83352 deleted from function.get-defined-constants by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139668@lists.php.net to get a copy of this message
Note Submitter: chris dot jacob at marksydney dot com Reason: 1 ---- How to: only define a USER constant if it hasn't already been defined. <?php // fetch an array of all the defined constants $tDefinedConstantsArray = get_defined_constants(true); // define a user constant if it does not already exist // (i.e. does not exist as a KEY in the USER defined constants; within the defined contants array) if(array_key_exists('MY_CONSTANT', $tDefinedConstantsArray['user']) == false) { define("MY_CONSTANT", "some value"); } ?>

« previous php.notes (#139668) next »