Is there a short-circuit OR in PHP that returns the left-most value?

前端 未结 6 2056
南笙
南笙 2020-12-09 16:57

In some languages, you can do

$a = $b OR $c OR die(\"no value\");

That is, the OR will short-circuit, only evaluating values from left to right

6条回答
  •  伪装坚强ぢ
    2020-12-09 17:24

    You can use just:

    $a = func1() or $a = func2() or $a = func3();
    

    or am I missing something?

提交回复
热议问题