Structure of the Problem Requirements
In this programme we will discuss about while lopp in php. How we can implement while loop in php. In our example we use while loop and display the number on screen and in second part of example we can use if else statement in while loop for understanding the While loop. Here is the source code of that Programmed that help you in better understanding.
SOURCE CODE
<html>
<head>
<title>Loops: while</title>
</head>
<body>
<?php /* while loops
while(expression)
statement;
{} around multi-line statements (like if-statements)
watch out for infinite loops
*/
// This loop outputs 0-10
$count = 0;
while ($count <= 10) {
echo $count . ", ";
$count++;
}
echo "<br />Count: {$count}";
?>
<br />
<?php
// Loops can be combined with if-statements
$count = 0;
while ($count <= 10) {
if ($count == 5) {
echo "FIVE, ";
} else {
echo $count . ", ";
}
$count++;
}
echo "<br />Count: {$count}";
?>
</body>
</html>
OUTPUT OF THE PROGRAM
Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.
0 comments:
Post a Comment