|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43339 2 == true returns true is confusing.
Submitted: 2007-11-19 21:46 UTC Modified: 2007-11-20 11:06 UTC
From: ken at smallboxsoftware dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 - 3 = ?
Subscribe to this entry?

 [2007-11-19 21:46 UTC] ken at smallboxsoftware dot net
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. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-20 11:06 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

That\'s part of PHP\'s type system. You might want to use === isntead of ==.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 15:05:45 2022 UTC