O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Logical and Relational Operators

Relational operators compare values and return either TRUE or FALSE. Logical operators perform logical operations on TRUE and FALSE. Values used with a logical operator are converted into booleans prior to being evaluated. For numerical values, zero will be interpreted as FALSE, and other values will be TRUE. Empty strings are considered be FALSE, and any nonempty string is TRUE. Table 2.5 lists the logical and relational operators.

Table 2.5. Logical and Relational Operators
OperatorOperation Performed
<Is Less Than
>Is Greater Than
<=Is Less Than or Equal To
>=Is Greater Than or Equal To
==Is Equal To
!=Is Not Equal To
AND &&And
OR ||Or
XORExclusive Or
!Not

Notice that the equality operator is very similar to the assignment ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required