Ifs, ands, or buts

From: Date: Wed, 27 Aug 2003 16:28:54 +0000
Subject: Ifs, ands, or buts
Groups: php.db 
Request: Send a blank email to php-db+get-30127@lists.php.net to get a copy of this message
Another one that should be easy that I am just not finding anywhere in the manual. How do I put an 'and' or an 'or' in an if statement? I know I could achieve the same results with multiple if statements, but that seems so inefficient. Lets say I wanted to check a bunch of fields to make sure they weren't empty. I can check one field by saying: if ($field1) { echo "Field 1 is not empty"; } Can't I just say: if ($field1 and $field2 and $field3 and $field4) { echo "All four fields are field in"; } Or if ($field1 or $field2 or $field3 or $field4) { echo "At least one of the four fields is filled in"; } ? Maybe its not the word "and" and "or" but maybe its && or || respectively? That's what I've seen in other languages that let you do this. I'm sure there must be a way to do this with PHP, too. Thanks for your help. Diana
diana@vivaladata.com                 "Will Work for Chocolate"
http://www.vivaladata.com           (and its worth every byte!)


« previous php.db (#30127) next »