PHP Lazy Boolean Evaluation

后端 未结 3 949
别那么骄傲
别那么骄傲 2020-12-10 00:52

I have a conditional statement thus:

if($boolean && expensiveOperation()){ ...}

Does PHP have lazy boolean evaluation, i.e. will it

3条回答
  •  借酒劲吻你
    2020-12-10 01:19

    PHP does have short circuit evaluation. Your example would be the proper use of it:

    http://en.wikipedia.org/wiki/Short-circuit_evaluation#Support_in_common_programming_languages

提交回复
热议问题