Re: why is it always an endless loop? [message #186151 is a reply to message #186140] |
Mon, 16 June 2014 18:09 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 16/06/14 18:06, richard wrote:
>
> $a="one"
> $b="one"
>
> while ($a=$b){echo "equal"; $b="two";)
>
> This simple code causes an endless loop.
> Why?
try this one instead and you see why:
$a="one"
$b="one"
while($a=$b) {
echo "equal a='{$a}', b={$b}\n";
$b="two";
}
> As soon as $b is changed, they are no longer equal, yet the loop continues.
> This does not happen in BASIC.
For BASIC lacks == and ===
> If it is placement, where then should $b be placed?
It's your compare which is incorrect, I don't remember how many times
you have made the same mistake over and over again.
Don't complain about the answers in the thread, be happy that people
haven't added you to filters to not see your posts.
--
//Aho
|
|
|