php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62228 equal operator does not correct
Submitted: 2012-06-05 02:51 UTC Modified: 2012-06-05 05:36 UTC
From: starway49 at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.13 OS: ALL
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: starway49 at hotmail dot com
New email:
PHP Version: OS:

 

 [2012-06-05 02:51 UTC] starway49 at hotmail dot com
Description:
------------
this problom may happen in PHP5.2~5.4

<?php
    echo '0X00' == '0E04';  //return 1

    if ('0X00' == '0E04') {
    	echo '0X00 = 0E04'; //the answer is true?!
    }
?>

Test script:
---------------
<?php
    echo '0X00' == '0E04';  //return 1

    if ('0X00' == '0E04') {
    	echo '0X00 = 0E04'; //the answer is true
    }
?>

Expected result:
----------------
if ('0X00' == '0E04')
this should return false.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-05 05:32 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2012-06-05 05:32 UTC] laruence@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

0x00 -> hex 0
0e04 -> science nonation 0 * 10^4 

they all are numeric string. php will convert them to integer before comparing.
 [2012-06-05 05:36 UTC] laruence@php.net
s#convert to integer#convert to number#g
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC