note 18257 added to function.define

From: Date: Wed, 16 Jan 2002 12:18:02 +0000
Subject: note 18257 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-24876@lists.php.net to get a copy of this message
Define is not a preprocessor directive, you can put it into conditional statements, ecc.. This will work: if($lang=='english'){ define(PATH1,'en/file1.txt'); ... } else if($lang=='french') { define(PATH1,'fr/file1.txt'); ... } else { define(PATH1,'int/file1.txt'); ... } require(PATH1); ... You must define the constant before you use it, but in terms of execution time, not file position, again, this works: function test() { echo(TEST); } define(TEST,'defined!'); test(); -- http://www.php.net/manual/en/function.define.php http://master.php.net/manage/user-notes.php?action=edit+18257 http://master.php.net/manage/user-notes.php?action=delete+18257 http://master.php.net/manage/user-notes.php?action=reject+18257

« previous php.notes (#24876) next »