php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45495 logic related; "abc"==0 returns true
Submitted: 2008-07-12 17:33 UTC Modified: 2008-07-12 17:54 UTC
From: xamine at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.6 OS: FreeBSD and WIN
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: xamine at gmail dot com
New email:
PHP Version: OS:

 

 [2008-07-12 17:33 UTC] xamine at gmail dot com
Description:
------------
I think there is a bug in the logic when comparing a string to int(0).

I experience this bug on both MS windows and FreeBSD, on PHP 5.2.5 and PHP 5.2.6 and using Apache 2.0 / 1.3.

Reproduce code:
---------------
//Here is three ways of reproducing the same error.

var_dump("test"==0);
var_dump(("anotherTest"==0));

//... and finaly ...

$bool=("abc"==0);
var_dump($bool);

Expected result:
----------------
I expect them all to return bool(false), I expect only "0"==0 to return true.

Actual result:
--------------
They all return bool(true), nomather what string i compare to 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-12 17:54 UTC] felipe@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

See http://docs.php.net/manual/en/types.comparisons.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC