0
Will this cause infinite loop ..If yes/no ..explain
<? php $x=1; while (2> $x) { $x++; $x-=2; }
2 Antworten
+ 10
<? php
$x=1;
while (2> $x)
{
$x++;
$x-=2;
}
can be rewritten as
<? php
$x=1;
while ($x< 2)
{
$x-=1;
}
meaning $x is reduced by 1 in every iteration. So, $x always stays less than 2. Thus, it's an infinite loop.
+ 7
😁 you soustrat x value end loop now $x is always 1