bela_666 proszę nie mieszaj nowicjuszom w głowach .... te pętle
RÓŻNIĄ SI:
While loop - The idea of a loop is to do something over and over again until the task has been completed.The for loop is simply a while loop with a bit more code added to it. The common tasks that are covered by a for loop are:- Set a counter variable to some initial value.
- Check to see if the conditional statement is true.
- Execute the code within the loop.
- Increment a counter at the end of each iteration through the loop.
Nawet ta definicja nie jest do konca poprawna bo:
<?php
$i=1;
$j=1;
$k=1;
echo \"i=\".$i.\"tj=\".$j.\"tk=\".$k.\"n\"; for ($i++;$j<10;$k*=2)
{
echo \"i=\".$i.\"tj=\".$j.\"tk=\".$k.\"n\"; $j++;
}
?>
Powyższy kod wykona się a zmienne występujące w polach for nie mają ze sobą nic wspólnego
Mozna powiedzieć że
Kod
for (<a>,<b>,<c>)
{
<d>
}
rownowazne jest:
Kod
<a>
while (<b>)
{
<d>
<c>
}
ale nie że jest takie same.