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

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.

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

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 :

- $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 :

- 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.