RE: [PHP] Control Structure problem

From: Date: Wed, 17 Sep 2003 00:01:54 +0000
Subject: RE: [PHP] Control Structure problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-162806@lists.php.net to get a copy of this message
> This doesnt work as expected. > > if ( $var === "TEST ONE" || "TEST TWO" || "TEST THREE") { > > do something; > > } > > It returns true on all strings. Ive tried using the or operator > and the == but these fail as well. Any Ideas? It behaves exactly as expected. Try checking the manual section on control structures, I believe it explains that the syntax you are using is invalid. What you are saying is if ( $var === ("TEST ONE" || "TEST TWO" || "TEST THREE")) { ("TEST ONE" || "TEST TWO" || "TEST THREE") is always going to evaluate as true. I think what you want is if ( $var === "TEST ONE" || $var === "TEST TWO" || $var === "TEST THREE") {

« previous php.general (#162806) next »