Re: switch statement

From: Date: Fri, 22 Dec 2000 19:55:10 +0000
Subject: Re: switch statement
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-5422@lists.php.net to get a copy of this message
Thanks Toby, It's fun getting use to a new language. ""Toby Butzon"" <php-lists@imawebdesigner.com> wrote in message news:066101c06b9d$2b8c5af0$2b521d0c@ttcbwin2k... > Switch statements aren't made to work quite like that; PHP interprets each > case like this: > case ($something): > /* some code */ > break; > > ... is comparable to... > > if ( $QUERY_STRING == ($something) ) { > /* some code */ > } > > So if you run > > case <= 2000: > > you're always going to get an error. Case only evaluates equality. > > I'd say you ought to use an if statement anyway for clarity... > > Toby Butzon > [ criticism spurs improvement ] > > > ----- Original Message ----- > From: "Gary" <gcooke@radionics.com> > To: <php-db@lists.php.net> > Sent: Thursday, December 21, 2000 6:20 PM > Subject: [PHP-DB] switch statement > > > : Can anyone tell me how to do this, I'm pretty new to PHP. > : I want to use a switch statement with $QUERY_STRING and check with case if > : the $QUERY_STRING is actually a number and if it's between 200000 and > : 300000. Something like: > : > : switch($QUERY_STRING) > : { > : case >= 200000 && <= 300000: do something; > : } > : > : What am I doing wrong? > : > : Thanks > : > : > : > : -- > : PHP Database Mailing List (http://www.php.net/) > : To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > : For additional commands, e-mail: php-db-help@lists.php.net > : To contact the list administrators, e-mail: php-list-admin@lists.php.net > : > : > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#5422) next »