Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
if( $a == $b) { return true;} else { return false;}
如何为以下编写三元运算符?
是这样吗
if($a == $b)? return true; : return false;
您根本不需要三元运算符。只需返回这个,你就会得到正确的trueorfalse值。
true
false
return $a == $b;
你可以
return ($a == $b)
但是如果你真的想使用运营商
return ( ($a == $b) ? true : false)