Re: switch statement

From: Date: Thu, 21 Dec 2000 22:27:14 +0000
Subject: Re: switch statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-5398@lists.php.net to get a copy of this message
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 : :

« previous php.db (#5398) next »