php tutorial - PHP While Loop - php programming - learn php - php code - php script




 While Loop

Learn PHP - PHP tutorial - While Loop - PHP examples - PHP programs

  • While loops will be executed if the set of code for the particular condition is true.
  • If the condition becomes false, the statements within the loop stops executing and control passes to the next statement in the loop.
While Loop Conditional Structure In PHP

php scripts Syntax :

while (condition is true) 
{
    code will be executed;
}
click below button to copy the code. php tutorial - team

php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax - php function - php while loop

Sample Code in php : sample php program

<!DOCTYPE html>
<html>
    <head>
        <title>While-Loop</title>
    </head>
    <body>
        <?php
            $x = 10;
            while($x <= 20) 
            {
                echo "The number is: $x <br>";
                $x++;
            }
        ?>
    </body>
</html>
click below button to copy the code. php tutorial - team

php programmer Code Explanation :

Code Explanation for While Loop In PHP

  1. $x =10 is a variable.
  2. while($x <= 15) is the while loop which will continue to run as long as $x=10 is less than, or equal to 15 ($x <= 15). $x =10 will increase by 1 each time the loop runs ($x++) variable till 15.

php development Sample Output :

output for While Loop In PHP

  1. While loop will continue to run as long as $x=10 is less than, or equal to 15 ($x <= 15) which will increase by 1 each time the loop runs ($x++) till 15.


Related Searches to php while loop