note 63313 added to function.defined
| From: | gerry-05 at 4warding dot com | Date: | Sun, 19 Mar 2006 16:17:17 +0000 |
| Subject: | note 63313 added to function.defined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-106077@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 203.16.234.19
Probable Submitter: 202.89.181.92
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.defined.php
Edit -- http://master.php.net/note/edit/63313
Del: integrated -- http://master.php.net/note/delete/63313/integrated
Del: useless -- http://master.php.net/note/delete/63313/useless
Del: bad code -- http://master.php.net/note/delete/63313/bad+code
Del: spam -- http://master.php.net/note/delete/63313/spam
Del: non-english -- http://master.php.net/note/delete/63313/non-english
Del: in docs -- http://master.php.net/note/delete/63313/in+docs
Del: other reasons-- http://master.php.net/note/delete/63313
Reject -- http://master.php.net/note/reject/63313
Search -- http://master.php.net/manage/user-notes.php