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