php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53487 (integer) 0 == '_'
Submitted: 2010-12-06 17:45 UTC Modified: 2010-12-06 18:34 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kherrera at codealchemy dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: Irrelevant OS: Windows XP SP3
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: kherrera at codealchemy dot com
New email:
PHP Version: OS:

 

 [2010-12-06 17:45 UTC] kherrera at codealchemy dot com
Description:
------------
When testing the expression of integer "0" (zero) equals "_" (underscore), the 
result of the expression is true, when it should be false.

I could not select the proper PHP version number because it was not listed:

C:>php -v
PHP 5.3.2 (cli) (built: Mar  3 2010 20:36:54)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Test script:
---------------
<?php

    $index = 0;

    if ( $index == '_' )
        echo "Bug found.\n";

    else
        echo "No bug found.\n";

Expected result:
----------------
No bug found.

Actual result:
--------------
Bug found.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-06 18:07 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2010-12-06 18:07 UTC] pajoye@php.net
use ===. and try echo (int) '_';
 [2010-12-06 18:23 UTC] kherrera at codealchemy dot com
That's what I'm doing now, but why is this being flagged as bogus?

Zero is not equal to an underscore, typed or not.
 [2010-12-06 18:34 UTC] rasmus@php.net
Types matter.  What is the integer value of '_' ?  When you are comparing 
different types, one will be cast to the other.  When you cast '_' to an integer 
you get 0.  You either need to force both parameters to be of the same type 
yourself, or you need to use ===
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC