note 99361 added to language.types.boolean
| From: | passeyhead at gmail dot com | Date: | Thu, 12 Aug 2010 17:13:56 +0000 |
| Subject: | note 99361 added to language.types.boolean | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171619@lists.php.net to get a copy of this message | ||
In response to fyrye at torntech dot com's function, I took it one step further to this:
<?php
private function setBool($val)
{
return ((int)$val == 1 || $val === TRUE) ? TRUE : FALSE;
}
?>
My reasoning for the change was because the number 1 was being returned as false when in fact it
should be true. So, the only true values are true, '1', and 1. Everything else is false.
----
Server IP: 192.41.42.26
Probable Submitter: 168.212.224.2
----
Manual Page -- http://www.php.net/manual/en/language.types.boolean.php
Edit -- https://master.php.net/note/edit/99361
Del: integrated -- https://master.php.net/note/delete/99361/integrated
Del: useless -- https://master.php.net/note/delete/99361/useless
Del: bad code -- https://master.php.net/note/delete/99361/bad+code
Del: spam -- https://master.php.net/note/delete/99361/spam
Del: non-english -- https://master.php.net/note/delete/99361/non-english
Del: in docs -- https://master.php.net/note/delete/99361/in+docs
Del: other reasons-- https://master.php.net/note/delete/99361
Reject -- https://master.php.net/note/reject/99361
Search -- https://master.php.net/manage/user-notes.php