PHP 4.0 Bug #9186: string compare with "==" does not work correctly

From: Date: Fri, 09 Feb 2001 08:25:24 +0000
Subject: PHP 4.0 Bug #9186: string compare with "==" does not work correctly
Groups: php.dev 
Request: Send a blank email to php-dev+get-46067@lists.php.net to get a copy of this message
From: tom.anheyer@berlinonline.de Operating system: any PHP version: 4.0.4pl1 PHP Bug Type: Scripting Engine problem Bug description: string compare with "==" does not work correctly First the test script: <? $a = '012345678901234567'; $b = '012345678901234568'; echo ($a == $b) ? "a equal b\n" : "a not equal b\n"; echo ($a === $b) ? "a equal b\n" : "a not equal b\n"; printf ("as string: a=%s b=%s\n", $a, $b); printf ("as float: a=%.0f b=%.0f\n", $a, $b); printf ("as int: a=%d b=%d\n", $a, $b); ?> and its output: a equal b a not equal b as string: a=012345678901234567 b=012345678901234568 as float: a=12345678901234567 b=12345678901234567 as int: a=2147483647 b=2147483647 Zend trys to convert the arguments to numbers if both arguments are strings. This is not good and its not a feature. -- Edit Bug report at: http://bugs.php.net/?id=9186&edit=1

« previous php.dev (#46067) next »