i dont understand, why the echo is not just one time , i missed 1++ | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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++; } ?>

24th Nov 2019, 12:41 PM
Petra NoƩ
Petra NoƩ - avatar
2 Respostas
+ 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
24th Nov 2019, 1:03 PM
GAWEN STEASY
GAWEN STEASY - avatar
0
thx !!!!
24th Nov 2019, 1:15 PM
Petra NoƩ
Petra NoƩ - avatar