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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat May 10 01:01:28 2025 UTC