|
Posted by Toby A Inkster on 08/15/07 08:23
Water Cooler v2 wrote:
> what's the use of having constants in an interpreted language like
> php, when there's no compile cycle?
Readability: error_reporting(E_ALL) is self-documenting, whereas
error_reporting(6143) needs a comment to explain what it means.
Configuration: instead of littering "/home/me/webstuff/" all over your
code, use define('MY_WEBSTUFF', '/home/me/webstuff/') and litter
MY_WEBSTUFF all over your code. Then, if your webstuff ever changes, you
only need to change one line of code.
Yes, functions could be used in each case:
function E_ALL() { return 6143; }
function MY_WEBSTUFF() { return '/home/me/webstuff/'; }
but they have additional overhead and result in a perverse proliferation
of parentheses.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 55 days, 11:54.]
Fake Steve is Dead; Long Live Fake Bob!
http://tobyinkster.co.uk/blog/2007/08/13/fake-bob/
[Back to original message]
|