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

Evaluation of Boolean Expressions

The conditional statements in this chapter may be compound expressions, of course. PHP will evaluate an expression only to the point of determining its ultimate value. The classic situation is an expression that uses the or operator. PHP first evaluates the left side of the or operator. If this subexpression is true, then there is no need to proceed. The entire expression will be true. This can lead to unexpected functionality if you are embedding function calls or assignment statements in your boolean expressions, but this isn't a good idea anyway. However, there are ways to take advantage of this behavior. An example is testing for something that should be true and calling an error-handling routine on the right ...

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