Here is a sample of using a for loop in a PHP language.
Code:
<?php
for($var_x=1; $var_x<=5; $var_x++)
{
echo "Number: ".$var_x."<br/>";
}
?>
Here is a sample of using a for loop in a PHP language.
Code:
<?php
for($var_x=1; $var_x<=5; $var_x++)
{
echo "Number: ".$var_x."<br/>";
}
?>
This is a tutorial on how to use a while loop in a PHP. The output will be the same if you were going to use a for loop, the only difference is only the code itself and especially the concept of each loop and how this loop performs its action when the programmer run his/her program. Below is a sample illustration on how to code while loop in PHP.
PHP Code:<?php
$var_x = 1;
while($var_x <= 5)
{
echo "Number: ".$var_x."<br/>";
$var_x++;
}
?>You can try this with your own. If there are some comments or questions about this article just CLICK THIS LINK to be redirected to the forum page.