Friday, November 11, 2022

Using While Loop In PHP Easy Guide For Beginner

 Using While Loop In PHP







The while loop - Loops through a block of code as long as the specified condition is true.


// Print Hello World Using While Loop.
$counter = 0;
while ($counter < 10) {
echo "Hello World!" . "

";
$counter++;
}
echo "
";
// Print 0 to 10 using While Loop.
$counter = 0
;
while ($counter <= 10) {
echo $counter . "
";
$counter++;
}
// Reverse loop 10 to 0
echo "
";
$counter = 10;
while ($counter >= 0) {
echo $counter . "
";
$counter--;
}

0 comments

Post a Comment