Complete the code to start a while loop that runs as long as $count is less than 5.
<?php $count = 0; while ([1]) { echo $count . "\n"; $count++; } ?>
The while loop continues as long as the condition is true. Here, it should run while $count is less than 5.
Complete the code to increment $i by 2 inside the while loop.
<?php $i = 0; while ($i < 10) { echo $i . "\n"; [1]; } ?>
To increase $i by 2 each time, use $i += 2;.
Fix the error in the while loop condition to avoid an infinite loop.
<?php $num = 5; while ([1]) { echo $num . "\n"; $num--; } ?>
The condition should check if $num is greater than or equal to 0 to stop the loop properly.
Fill both blanks to create a while loop that prints numbers from 1 to 5.
<?php $num = 1; while ([1]) { echo $num . "\n"; [2]; } ?>
The loop should run while $num is less than or equal to 5, and $num should increase by 1 each time.
Fill all three blanks to create a while loop that prints even numbers from 2 to 10.
<?php $num = [1]; while ([2]) { echo $num . "\n"; [3]; } ?>
Start $num at 2, run the loop while $num is less than or equal to 10, and increase $num by 2 each time to print even numbers.