note 35064 added to language.constants
| From: | ewspencer at industrex dot com | Date: | Mon, 18 Aug 2003 11:30:39 +0000 |
| Subject: | note 35064 added to language.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54581@lists.php.net to get a copy of this message | ||
I find using the concatenation operator helps disambiguate value assignments with constants. For
example, setting constants in a global configuration file:
define('LOCATOR', "/locator");
define('CLASSES', LOCATOR."/code/classes");
define('FUNCTIONS', LOCATOR."/code/functions");
define('USERDIR', LOCATOR."/user");
Later, I can use the same convention when invoking a constant's value for static constructs
such as require() calls:
require_once(FUNCTIONS."/database.fnc");
require_once(FUNCTIONS."/randchar.fnc");
as well as dynamic constructs, typical of value assignment to variables:
$userid = randchar(8,'anc','u');
$usermap = USERDIR."/".$userid.".png";
The above convention works for me, and helps produce self-documenting code.
-- Erich
----
Manual Page -- http://www.php.net/manual/en/language.constants.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35064
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35064&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35064&report=yes