|
Posted by Toby A Inkster on 01/06/08 23:19
A Bit Narked wrote:
> And yet you can echo true. The output is '1'.
No -- you can't echo a boolean in PHP. Why you try, the boolean is
implicitly cast to a string.
This:
echo $bool;
is actually executed as if you coded this:
echo (string)$bool;
If you look up the manual on type casting, you'll find that FALSE is cast
to an empty string, and TRUE is cast to a non-empty string.
If you cast to an integer instead of a string, then you'll find that FALSE
is cast to 0, which seems to be what you want.
echo (int)FALSE;
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 7 days, 10:29.]
dhyana.pl/0.3
http://tobyinkster.co.uk/blog/2008/01/06/dhyana/
Navigation:
[Reply to this message]
|