:ZCE: Short form of if-statement
Someone explain this to me
<?php
$n = 15;
$a = ($n % 2 ? 'odd number' : 'even number');
echo $a;
?>
Ok, I can understand its if statement,
eval ? DO_IF_TRUE : DO_IF_FALSE;
that was for today
Ok, I can understand its if statement,
eval ? DO_IF_TRUE : DO_IF_FALSE;
that was for today
1 Comments:
$n % 2 will return remainder of division of n by 2. Dividing by 2 always return 1 or 0.
So, using php type conversion rules $n%2 will alway return true or false.
11:27 AM
Post a Comment
<< Home