Re: Logic
| From: | Steve Werby | Date: | Wed, 05 Dec 2001 03:05:08 +0000 |
| Subject: | Re: Logic | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76636@lists.php.net to get a copy of this message | ||
"Dan McCullough" <McWC@rocketmail.com> wrote:
> Question. I am trying to check to see if a certain piece of code should
be run. Here is an
> example.
> if ($type != "add") || ($type != "edit") || ($type != "delete")
> {//if this
or this or this then
> then run this code
As pointed out, your paranthesis will give an error. Also, || means OR and
I suspect you mean && which means AND. Why? Go through the logic and
you'll see that no matter what $type is, one of the 3 inequalities will be
true and since you use an || the entire if statement will evaluate to true.
Not what you want.
It might be easier to edit and follow your code if you rewrite as:
if ( ! in_array( $type, array( 'add', 'edit', 'delete' ) ) )
{
}
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/