While Repetition in PHP
In addition to the For ', we also can do the loop by using a While.
In addition to the For ', we also can do the loop by using a While.
Here is an example how to use while in PHP :
<html>
<head>
<title> While Repetition</title>
</head>
<body>
<center>
<?
$count = 1;
while ($count <=10)
{
print ("Line number $count<br>");
$count = $count + 1;
}
?>
</center>
</body>
</html>
If the script above is run it will appear as below.
Line number 1
Line number 2
Line number 3
Line number 4
Line number 5
Row number 6
Line number 7
Line number 8
Line number 9
Line number 10
Repetition will continue to run as long as the value of $count is less than or equal to 10.
0 comments:
Post a Comment