You are here: Re: use of constants in an interpreter environment « PHP Programming Language « IT news, forums, messages
Re: use of constants in an interpreter environment

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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация