note 118181 added to language.types.boolean
| From: | marklgr | Date: | Wed, 21 Oct 2015 14:22:27 +0000 |
| Subject: | note 118181 added to language.types.boolean | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203999@lists.php.net to get a copy of this message | ||
For those wondering why the string "0" is falsy, consider that a good deal of input data
is actually string-typed, even when it is semantically numeral.
PHP often tries to autoconvert these strings to numeral, as the programmer certainly intended (try
'echo "2"+3'). Consequently, PHP designers decided to treat 0 and "0"
similarly, ie. falsy, for consistency and to avoid bugs where the programmer believes he got a true
numeral that would happen to be truthy when zero.
----
Server IP: 72.52.91.14
Probable Submitter: 92.92.61.116
----
Manual Page -- http://php.net/manual/en/language.types.boolean.php
Edit -- https://master.php.net/note/edit/118181
Del: integrated -- https://master.php.net/note/delete/118181/integrated
Del: useless -- https://master.php.net/note/delete/118181/useless
Del: bad code -- https://master.php.net/note/delete/118181/bad+code
Del: spam -- https://master.php.net/note/delete/118181/spam
Del: non-english -- https://master.php.net/note/delete/118181/non-english
Del: in docs -- https://master.php.net/note/delete/118181/in+docs
Del: other reasons-- https://master.php.net/note/delete/118181
Reject -- https://master.php.net/note/reject/118181
Search -- https://master.php.net/manage/user-notes.php