Marco Demaio
Marco Demaio

Reputation: 34417

PHP short circuit lazy evaluation, where is it in the php.net manual?

Sorry if this sounds like a really silly question.

But I Googled the web and also Googled specifically both the php.net site and the stackoverflow.com site. I know PHP does short circuit lazy evaluation when using and, or, &&, || operators, but where is it stated loud and clear in the PHP manual???

I found only Wikipedia as the only 'trusted' source that say PHP does lazy evaluation on these operators.

Upvotes: 18

Views: 5958

Answers (2)

Paul Dixon
Paul Dixon

Reputation: 300975

This is not an uncommon feature of expression evaluation. The PHP manual page on logical operators makes a passing reference to it in one of the illustrative examples though.

Short circuit evaluation is a commonly exploited idiom, and you can rely on its continued support in the language, otherwise vast amounts of code would break!

Upvotes: 1

Mike B
Mike B

Reputation: 32155

Closest thing I can find to an 'official' mention of PHP's short-circuit implementation: http://php.net/manual/en/language.operators.logical.php

Upvotes: 9

Related Questions