0
i dont understand, why the echo is not just one time , i missed 1++
<?php $i = 1; while ($i =7) { echo "The value is $i <br />"; $i++; } ?>
2 Réponses
+ 3
Petra Noé
/*
<?php
$i = 1;
//initially assigned value 1
// while loop will execute till $i = 7
while ($i = 7) //while condition is true(non zero) so it will always execute the code and print till the time limit exceeds
{
echo "The value is $i <br />";
//post increment the value in which first value store in variable then it is incremented by 1
$i++;
}
?>
*/
<?php
$i = 1;
while ($i < 7)//take while condition less then 7 to print 1 to 6
{
echo "The value is $i <br />";
$i++;
}
?>
In your code while loop value is true non zero so while loop will be execute always
0
thx !!!!