Welcome to PHP
An Intranet Design
Magazine Tutorial
By Aaron Weiss
PHP Logical Operators
| Operator |
Name |
Description |
Example |
Yield |
and
|
And |
True if both lefthand and righthand expressions are
true. |
(5>2) and (3>2)
(2>5) and (3>2)
|
true
false
|
or
|
Or |
True if either lefthand or righthand expression is
true. |
(5>2) or (2>7)
("h">"a") or (1<3)
|
true
true
|
xor
|
Exclusive Or |
True if either lefthand or righthand expression is
true unless both are true. |
("ar">"ac") xor (9>2)
(3==3) xor ("f"=="f")
|
true
false
|
!
|
Not |
Negates the expression it precedes, true if the expression
is not true. |
!("small"<"smell")
|
false
|
All of these operators can certainly be exhausting!
Just as eye fatigue sets in, a jolt! We're about to string together everything
we've learned so far, with the magic of control statements. Things get much
more exciting from here on in, for those of us excited by this sort of thing
(and who admit it).
Control Statements >
< PHP Comparison Operators