note 63313 deleted from function.defined by mazzanet

From: Date: Mon, 20 Mar 2006 10:38:08 +0000
Subject: note 63313 deleted from function.defined by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106094@lists.php.net to get a copy of this message
Note Submitter: gerry-05 at 4warding dot com ---- Using this function it is possible to set a default value for a constant. This allows users to set the value of constants used in your script, from within their own. Which means your script remains in it's original state. yourScript.php: <?php if(!defined('CONST_VAL')) define('CONST_VAL', 'Default Value'); echo CONST_VAL; ?> userScript.php: <? include 'yourScript.php'; define('CONST_VAL', 'Hello World!'); ?> If you tried just defining the constant again without using the !defined() check, you would receive a "Constant CONST_VAL already defined" notice.

« previous php.notes (#106094) next »