|
You can use define when you have alot of php files included in each other and want to define a variable that will never change.
I personally use it alot for paths. For sample you don't want to rewrite the path of your image folder evry time you use it.
define('IMAGE_PATH','site/files/lost/somewhere/ontheserver/images/');
echo "<img src='IMAGE_PATH$image'>";
you can notice that you don't need to use $ or any " because IMAGE_PATH will be replaced by 'site/files/lost/somewhere/ontheserver/images/' before the script is compiled. Its like if you would use "replace" in a text file or str_replace on a string.
i also personally use it for option, for sample if you want to put your website on debug mode.
define('MODE','1'); // 0 = normal, 1 = debug
Last edited by Bakunin; 09-21-2007 at 02:42 AM..
|