faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes

Entry

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/'); What does this means? It is from Zen-cart coding

Mar 20th, 2008 17:12
ha mo, Jason Benson, Lynn Tan,


define is a built in php function that creates (or defines) a constant.
A constant is a type of data that, once defined, will not change 
throughout your script.
Examples:
define("MyCONSTANT", "Hello world.");
echo MyCONSTANT; // outputs "Hello world."
Or in your asked about example
define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/'); 
echo DIR_WS_ICONS; // outputs "whatever is in DIR_WS_IMAGES and icons/"
the define function also has an optional boolean parameter for case 
insenstive functionality.
define("MyCONSTANT", "Hello world.", true); 
echo MyCONSTANT; // outputs "Hello world."
echo myconstant; // outputs "Hello world."
if the 3rd parameter in the above example were false, the 2nd example 
of "echo myconstant;" would only return something if there was an 
additional constant defined as "myconstant" as opposed to "MyCONSTANT"
See: http://us2.php.net/manual/en/function.constant.php
and: http://us2.php.net/manual/en/function.define.php
Hope that helps!
JB
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com