我喜欢在
JavaScript中这样做:
function (a,b,c) { var foo = a || b || c; return foo.bar; }
PHP 5.3引入了?:运算符(不要与三元条件,go图相混淆).我不使用PHP,但我想象会是这样的:
原文链接:https://www.f2er.com/php/139719.html$foo = $a ?: $b ?: $c
见:http://php.net/manual/en/language.operators.comparison.php
Since PHP 5.3,it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE,and expr3 otherwise.
快乐编码.