SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Basic Loops

PHP while loop statement script and example

While loop in PHP is very simple and similar to while loop in C programming. In PHP while loop the condition is checked at the beginning of the loop and the statement inside is executed till the end of the loop, then again the condition is checked and loop executed. Like this loop is continued till the condition became false and  the loop is then stopped. Here if the condition became false inside the loop then also the loop continue to execute till the next time the condition is checked.  Here is one simple example of while loop.
$j=5; // we assigned a value to the variable here
while($j <10 ){   // loop starts if condition is true
echo " value of \$j= $j <br>";
What is the output of this?
 value of $j= 5 
value of $j= 6
value of $j= 7
value of $j= 8
value of $j= 9
Here we are checking the while condition at the starting of the loop. So the execution of the loop will be done only if condition is satisfied at the beginning. We can read on the difference between do while loop and while loop here.

Be the first to post comment on this article :

Post Comment This is for short comments only. Use the forum for more discussions.
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer