You are here: Re: if...else - in which order « PHP Programming Language « IT news, forums, messages
Re: if...else - in which order

Posted by Toby Inkster on 11/01/06 13:10

Sonnich wrote:

> The question is, where the else will react too. Usually it should be
> the last if.

It always matches the inner-most /if/ for which there are no interleaving
statements. (There is no "usually" about it.)

> In general I put {} around just to be sure.

When nesting /if/s and using /else/, then it's certainly a good idea to
use the braces to indicate what is nested within what else. It will spare
your sanity a few months down the line if you have to edit that code again!

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

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

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