Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: why is it always an endless loop? Date: Mon, 16 Jun 2014 20:09:30 +0200 Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 96hjHxshEP0dTPHDD5svIw9qOL//lFvqq5BoYzGVH8L51AD5DQ Cancel-Lock: sha1:s3EkPxM6IEzi3AakV37KtFyR+LA= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Xref: csiph.com comp.lang.php:13886 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