php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34426 implicit string casting problem
Submitted: 2005-09-08 12:44 UTC Modified: 2005-09-08 17:47 UTC
From: mbphp at netzone dot ch Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.0 OS: Linux
Private report: No CVE-ID: None
 [2005-09-08 12:44 UTC] mbphp at netzone dot ch
Description:
------------
compare of 2 string with numbers >> implicit casting 

$a="1.5";
$b="1.50";

$a==$b gives true. 

which is not correct


both are strings, so casting to another type is not ucorrect i think. if the variables are of different type casting is ok but not if both are of the same type. 




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-08 12:48 UTC] tony2001@php.net
Use === operator for that.
 [2005-09-08 17:47 UTC] mbphp at netzone dot ch
yes, i know that it works with ===, but i think the behaviour is not correct.

why is there a type-casting if both operators are strings? 
it is slower only and the result is not correct.
if one of the operators is a numeric variable (float, int, ...) type-casting make sense, but not if both are strings.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Nov 28 21:00:01 2025 UTC