Reply to Re: There's got to be a better way

Your name:

Reply:


Posted by shimmyshack on 03/24/07 19:06

On 24 Mar, 15:37, Mary Pegg <inva...@invalid.com> wrote:
> Rami Elomaa wrote:
> > Let's try again, shall we.
>
> > for($counter=1;$counter<6;$counter++)
> > if (isset($c['s']['a'.$counter]))
> > echo $c['s']['a'.$counter]."<br>";
>

> what I've got anyway. There's lots of other things coming out of

which is why you shouldnt be doing it this way

> $c['s'], and the existing way is arguably more readable.

that's a daft reason, its completely unmaintainable and unextensible
no more readable to someone familiar with other basic php constructs
what if you start learning about XSS and decide you need to protect
yourself against it, then you will have to find examples such as this
and change them all to


if (isset($c['s']['a5'])) echo htmlentities($c['s']['a1'])."<br>";
..
..
..
if (isset($c['s']['a5'])) echo htmlentities($c['s']['a5'])."<br>";
that's alot of work for sake of sticking with what _you_ find more
readable


and what if you then decide you need your pages to validate to xhtml?
oh dear another trip through all your scripts:


if (isset($c['s']['a5'])) echo htmlentities($c['s']['a1'])."<br />";
..
..
..
if (isset($c['s']['a5'])) echo htmlentities($c['s']['a5'])."<br />";


what if you add more tha a5, or if you change the keys
uh oh!

there are standards in programming, designed to make code more
acceptable to others coming after you


all the chages above and more are so simple with Rani's method. If you
can't take good advice don't ask for it.

[Back to original 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

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