RE: [PHP] if statement with or comparison (newbie)

From: Date: Fri, 08 Sep 2006 22:06:11 +0000
Subject: RE: [PHP] if statement with or comparison (newbie)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241514@lists.php.net to get a copy of this message
On Fri, 2006-09-08 at 15:30 -0600, Jeremy Privett wrote: > Well, it could be this, too: > > switch( $_REQUEST['id'] ) { > case "white": > echo "Right color."; > break; > > case "black": > echo "Right color."; > break; > > default: > echo "Wrong color."; > break; > } Ugh, if you're going to use a big ugly case statement for something so trivial at least make use of the fall-through feature: <?php switch( $_REQUEST['id'] ) { case 'white': case 'black': { echo 'Right color.'; break; } default: { echo 'Wrong color.'; } } ?> Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#241514) next »