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

久未见 提交于 2019-11-26 12:29:53

问题


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.


回答1:


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




回答2:


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!



来源:https://stackoverflow.com/questions/3220919/php-short-circuit-lazy-evaluation-where-is-it-in-the-php-net-manual

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!