Tuesday, July 20, 2010
LOOP
Loop is used to repeat the PHP codes. If you want to repeat the codes of PHP for several conditions, you don’t have to write it all, just use loop.
WHILE
While is used to loop the codes inside the {} when the condition is TRUE.
For example:
<?
$a = 1;
while ($a < 4) {
echo ($a);
$a = ++$a;}
?>
FOR
FOR is loop method that the counter of the variable is declared for first time.
For example:
for ($var= 1; $var <= 5; $var=++$var)
{
echo $var;
}
Subscribe to:
Post Comments (Atom)
Currently have 0 comments: