You are here: Re: coding tip to prevent comparisons becoming assignments « PHP Programming Language « IT news, forums, messages
Re: coding tip to prevent comparisons becoming assignments

Posted by Oli Filth on 03/21/06 12:42

Peter Fox said the following on 21/03/2006 09:22:
>
> Here is a precis of my standard lecture (shortly to be a book) on equals.
>
>
> The use of = and == is *full* of traps
>
> $totalCake = 100;
> $slices = 7;
> $slice = $totalCake / $slices;
> $cakeLeft = $totalCake;
> while ($cakeLeft != 0){ // will this loop terminate? Always?
> $cakeLeft = $cakeLeft - $slice;
> }
> // Crumbs!!


How does that demonstrate the pitfalls of = and == ?


--
Oli

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация