php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ken at smallboxsoftware dot net
New email:
PHP Version: OS:

 

 [2007-11-19 21:46 UTC] 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. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-20 11:06 UTC] johannes@php.net
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 ==.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 16:03:34 2022 UTC