php tutorial - PHP While Loop - php programming - learn php - php code - php script
![While Loop](https://wikitechy.com/php/img/php-images/while.gif)
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 While Loop Conditional Structure In PHP](https://wikitechy.com/php/img/php-images/php-while-loop.png)
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](https://wikitechy.com/php/img/php-images/php-while-loop-statement.png)
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 Code Explanation for While Loop In PHP](https://wikitechy.com/php/img/php-images/code-explanation-php-while-loop.png)
- $x =10 is a variable.
- 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 output for While Loop In PHP](https://wikitechy.com/php/img/php-images/output-for-php-while-loop.png)
- 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.