#43339 [Opn->Bgs]: 2 == true returns true is confusing.
| From: | johannes@php.net | Date: | Tue, 20 Nov 2007 11:06:52 +0000 |
| Subject: | #43339 [Opn->Bgs]: 2 == true returns true is confusing. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119876@lists.php.net to get a copy of this message | ||
ID: 43339
Updated by: johannes@php.net
Reported By: ken at smallboxsoftware dot net
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
PHP Version: 5.2.5
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
That's part of PHP's type system. You might want to use === isntead of
==.
Previous Comments:
------------------------------------------------------------------------
[2007-11-19 21:46:49] ken at smallboxsoftware dot net
Description:
------------
It is not very intuitive to me that 2 == true returns true. Especially
since echo true displays 1 on the screen.
I would rather see a boolean casted to an integer than an integer
casted to a boolean during comparison, but this would probably cause
compatibility issues. Failing that, perhaps if echoing a boolean value
it should display either true or false instead of 0 or 1? Then you
wouldn't be left thinking that these are integers at their core as they
are in C.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43339&edit=1