Re: if syntax using multiple conditions

From: Date: Mon, 13 Sep 2004 16:55:40 +0000
Subject: Re: if syntax using multiple conditions
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-196525@lists.php.net to get a copy of this message
On Mon, 13 Sep 2004 11:32:00 -0500, Brian Anderson <listread@arielpremium.com> wrote: > What is the proper syndax in an if statement for containing multiple conditions? > > example: > > if ( condition1 && condition2 ) { > > dothis; > } > > if ( condition1 && (condition2 || condition3) ) { > > dothis; > } Looks good to me. > I am trying to translate this from asp to php: > > If WhichAction = 7 And (InStr(filename, "\") Or InStr(filename, "/") Or > (Left(filename, 1) = chr(32)) Or InStr(filename, "*") Or InStr(filename, "?") Or > InStr(filename, "|") Or InStr(filename, "<") Or InStr(filename, > ">") Or InStr(filename, ":") Or InStr(filename, """") Or > InStr(filename, "'")) Then > messages = "Bad filename" > filename = "" > WhichAction = 0 > End If I'd use a regular expression so as to match all those symbols with one command. Check out eregi() or maybe strstr(). -- Greg Donald http://destiney.com/

« previous php.general (#196525) next »