RE: [PHP] True || False ?
| From: | Tim Ward | Date: | Fri, 16 Feb 2001 09:41:11 +0000 |
| Subject: | RE: [PHP] True || False ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-40121@lists.php.net to get a copy of this message | ||
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?
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Toby Butzon [mailto:php-lists@imawebdesigner.com]
> Sent: 16 February 2001 04:49
> To: Jonathan Sharp
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] True || False ?
>
>
> Yes, you can return false.
>
> As for "true booleans", PHP doesn't really have a boolean
> type - it does
> have a sense of "true" and "not true" though. You can return false (a
> case-insensitive constant with the value 0) or true (whose value is
> probably 1 but could really be anything other than 0 or the empty
> string).
>
> You can of course evaluate a true/false value as a regular
> condition...
> if (someFunc()) {
> // do something if someFunc returns true
> } else {
> // do something if someFunc returns false
> }
>
> ..You get the idea.
>
> --toby
>
> Jonathan Sharp wrote:
> >
> > How does php handle true and false? Do they act as true booleans?
> >
> > Can I do?
> >
> > function foo()
> > {
> > return false;
> > }
> >
> > Thanks,
> > -Jonathan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>