- 1
Pls correct this my code i want to write Even and Odd number.
<?php for($a=0;$a<100;$a++){ if($a℅2==0){ echo"this is even number:".$a."<br/>"; } else { echo"this is odd number".$a."<br/>"; } } ?>
2 Respuestas
+ 5
use %
+ 4
short version:
<?php
for($i=0;$i<100;$i++){
echo $i." is ".(($i%2==0) ? "even" : "odd") ."<br>";
}
?>