On Tue, 6 Feb 2007, Tris wrote:
> However, I've seen sites (PHPMyAdmin springs to mind?) where the
> language include uses DEFINE..
>
> What is the difference, and why is one better than the other..?

define() is used when you want to define a constant.  A constant is
something that isn't going to change during the execution of the script.

For example,

define('LANG', 'english');

if (LANG == 'english') {
    print "Something in English";
}

The equivalent with a variable:

$lang = 'english';

if ($lang == 'english') {
    print "Something in English";
}


The constant has the advantage of knowing it won't change, you can't
accidentally do if (LANG = 'english') (the time-honoured assignment
instead of test for equality - the cause of many a keyboard->programmer's
forehead interface).  Also, I'd guess that PHP might be able to do some
optimisations for constants, since it knows they're not going to be
changing, but that's purely speculation on my part.

Cheers

Dave P



____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
       Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to