Print Even Numbers in PHP

Print Even Numbers in PHP

<?php
$i = 1;  // Statement initialises i to 1
echo “This will print even numbers between 1 to 11”; // Prints the statement in double quotes
while($i <= 11) { // Check whether condition is true
if ( $i % 2==0) // Checks divisibility by two
echo “$i</br>”; // Prints Even numbers
$i++; // Increases value of i by 1
}
?>
___________________________
Output-
2
4
6
8
10
___________________________

Leave a Comment

Your email address will not be published. Required fields are marked *

©Postnetwork-All rights reserved.