php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52541 10 == '10px' => true !
Submitted: 2010-08-05 10:12 UTC Modified: 2010-08-05 12:35 UTC
From: developer dot mahmoud at gmail dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.3SVN-2010-08-05 (SVN) OS: win 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: developer dot mahmoud at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-05 10:12 UTC] developer dot mahmoud at gmail dot com
Description:
------------
when i compare between number and string it compare only the number in the string


Test script:
---------------
$id = 10;

if($id == '10px')
   echo 'yes'; // it say yes ! 

Expected result:
----------------
it say yes !
but 10 != '10px'


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-05 10:16 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2010-08-05 10:16 UTC] rasmus@php.net
Use === if you want a strict comparison.  Otherwise since you are comparing an int 
to a string, it will compare the integer value of the string, which is 10 to 10 
and it will match.
 [2010-08-05 12:35 UTC] developer dot mahmoud at gmail dot com
i understand now
thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 00:01:33 2024 UTC