You are writing a PHP script and you want to execute a block of code as long as a certain condition is true. How would you do this using a while loop?

  • Write the condition inside the while loop's parentheses
  • Write the condition after the while keyword
  • Write the condition in a separate line with braces
  • Write the condition after the code block
To execute a block of code as long as a certain condition is true using a while loop in PHP, you would write the condition inside the while loop's parentheses. The code block following the while loop will be executed repeatedly until the condition becomes false. The condition is checked before each iteration of the loop, and if it evaluates to true, the code block will execute. If the condition initially evaluates to false, the code block will not execute at all. 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 *