#23110 [NEW]: Ugly behaviour of == (and ===)
| From: | kyrael at web dot de | Date: | Tue, 08 Apr 2003 11:43:46 +0000 |
| Subject: | #23110 [NEW]: Ugly behaviour of == (and ===) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-37343@lists.php.net to get a copy of this message | ||
From: kyrael at web dot de
Operating system: Linux
PHP version: 4.3.1
PHP Bug Type: Feature/Change Request
Bug description: Ugly behaviour of == (and ===)
<?php
list($var1,$var2)=array("1e1","10");
var_dump($var1);var_dump($var2);
var_dump($var1==$var2);
var_dump($var1===$var2);
?>
string(3) "1e1"
string(2) "10"
bool(true)
bool(false)
This behaviour is ugly - both operands are strings, and they are clearly
not equal. '1e0' and '1.0' and '1' are "equal" too. Same
with '3.20' and
'3.2'. Does PHP think i am stupid and unable to type numbers when i want
them?
According to the manual, == returns true if the two operands are equal,
and === returns true if the operands are equal and of the same type. ==
says they are equal, and according to var_dump they are both strings - why
doesn't === return true then? So this behaviour is neither logical nor
documented. String comparison, even with == when both operands are
strings, should return 'equal' if and only if the strings are really
equal. Wouldn't be PHP5 a chance to change this?
--
Edit bug report at http://bugs.php.net/?id=23110&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23110&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23110&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23110&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23110&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23110&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23110&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23110&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23110&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23110&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23110&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23110&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23110&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23110&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23110&r=gnused