You are here: Re: Possibile bug? « PHP Programming Language « IT news, forums, messages
Re: Possibile bug?

Posted by peter on 03/23/07 06:49

>> It should (and I presume does) return 1.
>
> Actually, it returns bool(true).
>
>> I presume you just don't know why.
>
> You're correct. :-) Why?
>
> This code:
>
> if ( $str = foo() ) var_dump($str);
>
> returns the string - as I expected.
>
> foo() is always - correctly - executed only once.
> I just can't understand this behaviour.

$str = foo() is always going to be true as you are assigning $str to foo()
if you are trying to see if what is returned by foo() is the same as $str
then you should use == or ===

 

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

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