Constants are useful when a variable will remain exactly the same (constant) through the life of a script. e.g a script I wrote to calculate dates be it in the past or future would have constant values for how many seconds are in a day or a week. to be used in calculations. e.g:
define("SECONDSINWEEK", 604800); // Number of seconds in week define("SECONDSINDAY", 86400); // Number of seconds in day $iDayOfWeek = 1; // 0 to 6 - 0 being Sunday $iNumWeeks = 12; // Number of weeks to lookback $iOffsetTimestamp = 0; // Initialize this var $iCurTime = time(); $iCurDay = date("w", $iCurTime); ^^^ The above constants will always be what they are defined as. Constant :-) Also another advantage of using constants, is that it can make your code easier to read. Usually constant names are declare in uppercase, which helps to break up your code. HTH Craig "Al" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Can someone explain to me the value of using defined custom constants, > in the context of good coding practice. > > I don't recall ever seeing define() used in the scripts I've seen and > only the characteristics are described in the my php book and the php > manual; but, not the use. > > Thanks..... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php