PHP While Loop: Print Even Numbers

You can use the following code to output even numbers using a while loop.

$num = 0;

while ($num <= 10) {
    if ($num % 2 == 0) {
        echo $num . "<br>";
    }
    $num++;
}

This code will output 0, 2, 4, 6, 8, 10, all of which are even numbers. You can modify the loop condition and output range as needed.

bannerAds