开发者

Ternary operatory for the stament

if( $a == $b) { return true;} 
else { return false;}

how to write a ternary operater for the following ?

is this the way

if($a == $b)? return true; : return false开发者_运维知识库;


You don't need the ternary operator at all. Just return this and you'll get the correct true or false value.

return $a == $b;


You could just

return ($a == $b)

But if you really want to use the operator

return ( ($a == $b) ? true : false)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜