In this tutorials.We teach you "Iteration Contructs In PHP".This Source code has been written by T4VN Team. so, if you want to develop it, please contact us. Thanks for your interested in this code.
Loop in PHP is used to iterate through a section in an application. This is used frequently in many applications.
We will start with a basic loop and then move to adding different requirements to it. Here is the basic syntax for loop.
1- While Loop + While loop in PHP is very simple and similar to while loop in C programming.
+ A while statement repeats a loop as long as a specified condition is true.
while (condition is true)
{
// statements to perform
}
Example :
PHP Tutorials :
<?
i=1;
while (i<=12)
{
echo "This is example for Basic PHP";
i=i+1;
}
?>
2- For Loop
Basic syntax for "For Loop"
for (initialization;condition;increment)
{
//statements to perform
}
3- do-while LOOP 'do-while' loop is similar to while loop and the only difference here is that the set of statements are executed first and the condition is checked next.
Basic syntax for "Do-While Loop"
do
{
// set of statements that will be executed
}
while(condition)
Example :
PHP Tutorials :
<?
$a=0;
do
{
echo"This is example for Basic PHP";
}while($a!=0)
?>