note 80648 added to language.types.boolean
| From: | Wackzingo at osu1 dot php dot net | Date: | Sun, 27 Jan 2008 14:39:43 +0000 |
| Subject: | note 80648 added to language.types.boolean | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135438@lists.php.net to get a copy of this message | ||
It is correct that TRUE or FALSE should not be used as constants for the numbers 0 and 1. But there
may be times when it might be helpful to see the value of the Boolean as a 1 or 0. Here's how
to do it.
$var1 = TRUE;
$var2 = FALSE;
echo $var1; // Will display the number 1
echo $var2; //Will display nothing
To get it to display the number 0 for a false value you have to typecast it:
echo (int)$var2; //This will display the number 0 for false.
----
Server IP: 208.69.120.35
Probable Submitter: 24.113.52.142
----
Manual Page -- http://www.php.net/manual/en/language.types.boolean.php
Edit -- https://master.php.net/note/edit/80648
Del: integrated -- https://master.php.net/note/delete/80648/integrated
Del: useless -- https://master.php.net/note/delete/80648/useless
Del: bad code -- https://master.php.net/note/delete/80648/bad+code
Del: spam -- https://master.php.net/note/delete/80648/spam
Del: non-english -- https://master.php.net/note/delete/80648/non-english
Del: in docs -- https://master.php.net/note/delete/80648/in+docs
Del: other reasons-- https://master.php.net/note/delete/80648
Reject -- https://master.php.net/note/reject/80648
Search -- https://master.php.net/manage/user-notes.php