Home Tutorial Php Phpbasics Tutorial PHP Do While Loop

 
 

Share on Google+Share on Google+
PHP Do While Loop
Posted on: February 15, 2010 at 12:00 AM
Advertisement
In the current tutorial you will come to know about Do-While loop function in PHP. The Do-While loop function is another type of loop which runs at least once, since this loop checks the condition after executing the code within.

Do-While Loop Function PHP:

PHP Do-While loop method is another type of loop which runs at least once, since this loop checks the condition after executing the code within. We generally use Do-While loop  when the iteration must run at least once despite of the validity of the variable. In Do-While loop we need to initialize the variable first the coding within the loop executes and at last the this loop checks the condition. We should change the value of the variable within the loop.

PHP do while loop Example:

<?php

$i=34;

do{

echo "Value of \$i is $i <br/>";

$i++;

}while($i<11);

?>

Output:

Value of $i is 34

Exaplanation:

In the above example, value of $i is not valid but do-while loop runs at least one time despite the validity of the variable.

Advertisement

Related Tags for PHP Do While Loop:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 15, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com