Re: Using the OR operator in an IF statement

From: Date: Sat, 08 Jan 2005 12:36:03 +0000
Subject: Re: Using the OR operator in an IF statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-205864@lists.php.net to get a copy of this message
Tim Burgan wrote:
Hello, Can someone please correct me on my efforts below. If I have a condition where I want to test if a variable is not equal to "student", "staff", or "admin".. what's the simplest was to achieve that? Here's what I tried.. that didn't work: <?php if ( ($_POST['usertype'] != "student") || ($_POST['usertype'] != "staff") || ($_POST['usertype'] != "admin") ) {
     // ...
} ?>
use && instead of || In english, you'd say "if the usertype is not student and not staff and not admin, then we're OK." or "if the usertype is neither student, nor staff, nor admin" neither/nor is implemented using !=/&& Greg

« previous php.general (#205864) next »