Re: Boolean weirdness?
| From: | Andrei Zmievski | Date: | Thu, 17 May 2001 16:03:23 +0000 |
| Subject: | Re: Boolean weirdness? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-55632@lists.php.net to get a copy of this message | ||
On Thu, 17 May 2001, Sebastian Bergmann wrote:
> Hey there,
>
> I was just bitten by a - IMHO - weirdness with boolean values:
>
> <?php
> $foo = -1;
> if ($foo) { print "bar"; }
> ?>
>
> The code above print 'bar'. I would expect if($x) t return true if $x
> is an integer and greater that zero. This is what my intuition tells me
> :)
Anything that's not 0 is true.
-Andrei
"Try to spend the next 30 seconds not thinking
about a blue-eyed polar bear." -Feodor Dostoevsky