Re: True || False ?
| From: | Robin Vickery | Date: | Fri, 16 Feb 2001 10:48:59 +0000 |
| Subject: | Re: True || False ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40125@lists.php.net to get a copy of this message | ||
>>>>> "MM" == Maxim Maletsky <maxim.maletsky@japaninc.net> writes:
> >>>>> Tim Ward writes:
> >
> > to take this a step further, PHP doesn't seem to have types at all
> > try ...
> >
> > echo 1 + true; // gives 2
> > echo 1 . true; // gives 11
> >
> > true is a constant that seems to equate to 1, false is 0. Or is
> > this just my interpretation?
> You are absolutely right. True = 1 False = 0
> make an if statement, or echo ...
> Cheers, Maxim Maletsky
Ummm... no, PHP does have types. You can see the difference between
true and 1 if you use the === operator in your if statement rather
than ==.
In your examples you were implicitly converting from a boolean type
to an integer or a string. Try this:
print gettype(true) . "<br>\n";
print gettype(0 + true) . "<br>\n";
print gettype('' . true) . "<br>\n";
-robin
--
Robin Vickery.................................................
BlueCarrots, 14th Floor, 20 Eastbourne Terrace, London, W2 6LE