You are here: Re: Multiple (OR ||) case usage « PHP Programming Language « IT news, forums, messages
Re: Multiple (OR ||) case usage

Posted by Toby A Inkster on 02/01/07 10:28

Uleric wrote:

> if ($myzone !== ("here") or ("there") or ("where")) { die: }

Try:

if ($myzone!='here' && $myzone!='there' && $myzone!='where') die;


Or, using De Morgan's Laws (boolean algebra law concerning the
relationship between NOT, AND and OR) you could alternatively use:

if (!( $myzone=='here' || $myzone=='there' || $myzone=='where' )) die;


Or, to make your code read a bit more sanely (but might actually run
slower!):

$allowed_states = array('here', 'there', 'where');
if (!in_array($myzone, $allowed_states)) die;


--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

 

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

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