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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 03:01:27 2024 UTC