php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74412 Comparison of string with 0 (integer zero) is returning boolean true
Submitted: 2017-04-11 10:49 UTC Modified: 2017-04-11 10:53 UTC
From: anil dot shinde1 at gmail dot com Assigned:
Status: Not a bug Package: PHP Language Specification
PHP Version: 7.0.17 OS: ubuntu0.16.04.4
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: anil dot shinde1 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-04-11 10:49 UTC] anil dot shinde1 at gmail dot com
Description:
------------
 Comparison of string with 0 (integer zero) is returning boolean true
 php -r "var_dump('A' == 0);"
 bool(true)

Test script:
---------------
 php -r "var_dump(('A' == 0));"
 bool(true)

Expected result:
----------------
Comparison of string with 0 (integer zero) should return boolean false

Actual result:
--------------
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-11 10:53 UTC] peehaa@php.net
-Status: Open +Status: Not a bug
 [2017-04-11 10:53 UTC] peehaa@php.net
This is because type juggling that occurs.

Do strict comparisons instead (===)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC