You are here: Re: '0' passed to function treated as 'null' « PHP Programming Language « IT news, forums, messages
Re: '0' passed to function treated as 'null'

Posted by My Pet Programmer on 12/28/07 17:35

rynato said:
> uh, nevermind. I figured it out. For posterity's sake here's the
> solution:
>
> instead of:
>
> if ($value)
>
> I changed that conditional to:
>
> if ($value != null || $value === 0)
>
> the value was passed into the function correctly (it still equalled 0)
> but for some reason 'if ($value)' was not sufficient for PHP to
> distinguish between a value of 0 and no value at all. Can someone
> explain this distinction to me? Thanks.
Binary notation: 1 is true, zero is false.

Extrapolated into most programming languages, 0 = false, all other
numbers usually = true when evaluated in boolean expressions

~A!

--
Anthony Levensalor
anthony@mypetprogrammer.com

Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. - Albert Einstein

 

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

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