Thursday, 25 October 2012

Loops

"while" loops

Syntax :

while (condition) {
  Statement
 } 
 

 Let's look at a simple example:

<html>
 <head>
 <title>Loops</title>

 </head>
 <body>

 <?php

 $x = 1;
  
 while ($x <= 5) {
    echo "<p>This text is repeated 50 times</p>";
    $x = $x + 1;
 }
 ?>

 </body>

 </html>
 
Output : 

This text is repeated 50 times
This text is repeated 50 times
This text is repeated 50 times
This text is repeated 50 times
This text is repeated 50 times

No comments:

Post a Comment