Which of the following are true about the while loop in PHP?

  • It is a pre-test loop
  • It may not execute at all if the condition is initially false
  • It always executes its block of code at least once
  • It is suitable for iterating over a block of code for a known number of times
The while loop in PHP is a pre-test loop, which means that the condition is evaluated before executing the block of code. If the condition is initially false, the block of code may not execute at all. However, if the condition is true, the block of code will execute repeatedly until the condition becomes false. The while loop is suitable for situations where the number of iterations is not known in advance, and the code block will execute as long as the condition remains true. Learn more: https://www.php.net/manual/en/control-structures.while.php
Add your answer
Loading...

Leave a comment

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