Evaluation of Boolean Expressions - PHP

The conditional statements discussed here 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 side of an or statement.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP Topics