note 83352 added to function.get-defined-constants
| From: | chris dot jacob at marksydney dot com | Date: | Thu, 22 May 2008 01:56:30 +0000 |
| Subject: | note 83352 added to function.get-defined-constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139598@lists.php.net to get a copy of this message | ||
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");
}
?>
----
Server IP: 117.104.160.194
Probable Submitter: 218.185.56.178
----
Manual Page -- http://www.php.net/manual/en/function.get-defined-constants.php
Edit -- https://master.php.net/note/edit/83352
Del: integrated -- https://master.php.net/note/delete/83352/integrated
Del: useless -- https://master.php.net/note/delete/83352/useless
Del: bad code -- https://master.php.net/note/delete/83352/bad+code
Del: spam -- https://master.php.net/note/delete/83352/spam
Del: non-english -- https://master.php.net/note/delete/83352/non-english
Del: in docs -- https://master.php.net/note/delete/83352/in+docs
Del: other reasons-- https://master.php.net/note/delete/83352
Reject -- https://master.php.net/note/reject/83352
Search -- https://master.php.net/manage/user-notes.php