Write program to create for loop
Count from 1 to 10 in steps of 1.
For each number, display whether that number is an odd or even number, and also display a message if the number is a prime number.
The following code uses the ? (ternary) operator and a switch construct to determine if each number is odd, even, or prime.
<?php for ( $i = 1; $i <= 10; $i++ ) { $oddEven = ( $i % 2 == 0 ) ? "Even" : "Odd"; switch ( $i ) { case 2: case 3: case 5: case 7: $prime = "Yes"; break; default: $prime = "No"; break; }/*from www. j ava 2 s . c o m*/ echo $i; echo '\n'; echo $oddEven; echo '\n'; echo $prime; echo '\n'; } ?>