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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 03:03:36 2021 UTC