Showing posts with label PHP While loop. Show all posts
Showing posts with label PHP While loop. Show all posts

Tuesday, April 9, 2024

PHP While loop

 

PHP While loop

PHP While loop


 Information :-

1] PHP while loop can be used to return from the same process as the loop.

2] The while loop repeats a block of code until the condition is FALSE. 

3] Exit the body loop when the condition is FALSE.

4]
This
 loop should be used if the number of iterations is unknown.

5] Element
 loop is also called Entry check loop because 
the condition is checked          before entering the loop body. 

6] This means diagnosing the condition first. If the condition is true,           the code block is executed.


Syntax :-



Flowchart :-

PHP while loop /output




PHP While Loop 

Example :-

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<?php
/*decending order in php*/
 $no =10;
 while ($no>0)
 {
    echo $no."<br>";
    $no --;
 }

 /**10,9,8,7,6,5,4,3,2,1 */
 
 
 
?>

</body>
</html>


PHP While Loop 

OUTPUT :-