You are here: Re: Code readability vs. execution time « PHP Programming Language « IT news, forums, messages
Re: Code readability vs. execution time

Posted by Rik Wasmus on 09/04/07 23:37

On Tue, 04 Sep 2007 19:33:00 +0200, Michael Fesser <netizen@gmx.de> wrot=
e:
> .oO(The Natural Philosopher)
>> Michael Fesser wrote:
>>>
>>> The second statement simply means that the value of $int, whatever i=
t
>>> may be, evaluates to FALSE.
>>>
>> but what is "false", in this context?
>
> The result after the type cast?

Yup.

>> Null length string? string
>> containing "0" Magic value?
>
> If you write
>
> if ($int) {...}
>
> then there's no other way for PHP than to cast the $int variable to a
> boolean, because that's what the 'if' statement expects. The manual
> explains in detail how this type casting works and which values evalua=
te
> to FALSE:
>
> Converting to boolean
> http://www.php.net/manual/en/language.types.boolean.php#language.types=
..boolean.casting
>
> If you don't want that, then you should not rely on the automatic type=

> juggling, but better explain to PHP what you actually want to test for=
:
>
> if ($int !=3D 0) {...}

Indeed (allthough: $int !=3D=3D 0). The cost of loose types is indeed a =
more =

strict comparison if needed (which is quite natural and simple once you =
=

get used to it).
-- =

Rik Wasmus

 

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

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