Your freedom is worth more than you think. Take advantage of it while you can.
Be smart - Be a Zend Cert Zend Certified Engineer.

Thursday, July 07, 2005

: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

1 Comments:

Anonymous Anonymous said...

$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