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;
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)