Reply to Re: if an multiple statements

Your name:

Reply:


Posted by Steve on 01/07/08 16:54

"Michael Fesser" <netizen@gmx.de> wrote in message
news:pmk4o3trg1johm5rcaiho04qaos5kbd5rg@4ax.com...
> .oO(jodleren)
>
>>How do IF behave in php?
>>
>>Say,
>>if( $goahead && copy($somefile1, $somefile2) )
>> echo "hello world";
>>
>>What if $goahead is false, will the if the fall, or test all of the
>>statements?
>
> PHP uses lazy evaluation. As soon as the result is known, the evaluation
> stops. Because of this behaviour you can write things like

more pragmatic than lazy. if one condition is false, there is no possible
way other &&'ed conditions could change that result...so, why continue the
evaluation?

most languages do it this way. of those that i've used, vb was the only one
that continued to blindly evaluate conditions. it wasn't until vb.net that
the AndAlso and OrElse short-circuit constructs were added - 'short-circuit'
being even more descriptive than 'lazy' or 'pragmatic'.

cheers.

[Back to original 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

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