ID: 28031 User updated by: yiwakiri at st dot rim dot or dot jp Reported By: yiwakiri at st dot rim dot or dot jp -Status: Feedback +Status: Open Bug Type: Scripting Engine problem Operating System: Windows 2k, XP, 98 PHP Version: 4.3.6, 4.3.7-dev New Comment:
Hi, wez Why does it deceive as a problem of strtol()? Although it is comparison of STRING and STRING, Is it a problem if strtol() is called? In Unix Like OS, it is not thought that strtol() is called. Previous Comments: ------------------------------------------------------------------------ [2004-04-19 15:31:14] [EMAIL PROTECTED] Most likely due to strtol() implementation in the M$ libc. Try using the === operator or strcmp() instead. (strings that look like numbers might be compared as numbers using the == operator) ------------------------------------------------------------------------ [2004-04-19 15:11:06] postings-php-bug at hans-spath dot de D:\PHP>ver Microsoft Windows XP [Version 5.1.2600] D:\PHP>lastest\php-cli -v PHP 4.3.7-dev (cli) (built: Apr 19 2004 14:16:52) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies D:\PHP>5.0.0RC1\php -v PHP 5.0.0RC1 (cli) (built: Mar 18 2004 18:20:03) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.0RC1, Copyright (c) 1998-2004 Zend Technologies D:\PHP>lastest\php-cli test\string_comparison.php 0x1 0x2 ( '0x1' == '0x2' ) = bool(false) D:\PHP>lastest\php-cli test\string_comparison.php 0d1 0d2 ( '0d1' == '0d2' ) = bool(true) D:\PHP>lastest\php-cli test\string_comparison.php 0d1x 0d2x ( '0d1x' == '0d2x' ) = bool(false) D:\PHP>lastest\php-cli test\string_comparison.php 0d1 0dx1 ( '0d1' == '0dx1' ) = bool(false) D:\PHP>lastest\php-cli test\string_comparison.php 0d1 0xd1 ( '0d1' == '0xd1' ) = bool(true) D:\PHP>lastest\php-cli test\string_comparison.php 0d1 0xd2 ( '0d1' == '0xd2' ) = bool(true) D:\PHP>lastest\php-cli test\string_comparison.php d1 xd2 ( 'd1' == 'xd2' ) = bool(false) D:\PHP>lastest\php-cli test\string_comparison.php d1 xd1 ( 'd1' == 'xd1' ) = bool(false) D:\PHP>lastest\php-cli test\string_comparison.php 0e9 0xe4 ( '0e9' == '0xe4' ) = bool(true) D:\PHP>5.0.0RC1\php test\string_comparison.php 0e9 0xe4 ( '0e9' == '0xe4' ) = bool(true) I wonder why this hasn't been discovered before. All my currently installed (win32) versions (4.3.[2346], 5.0.0RC1) suffer from this problem. ------------------------------------------------------------------------ [2004-04-19 10:34:31] yiwakiri at st dot rim dot or dot jp Hmm, I'm confused. Windows(2k, XP 98): C:\>php -r "var_dump('0d1' == '0d2');" (1) bool(true) C:\>php -r "var_dump('00d1' == '00d2');" (2) bool(false) C:\>php -r "var_dump('0a1' == '0a2');" (3) bool(false) Unix like OS: % php -r "var_dump('0d1' == '0d2');" (4) bool(false) % php -r "var_dump('0a1' == '0a2');" (5) bool(false) Only (1) does not bring a result to expect. ------------------------------------------------------------------------ [2004-04-19 02:24:43] yiwakiri at st dot rim dot or dot jp A snapshot is also the same behavior. C:\>php -v PHP 4.3.7-dev (cli) (built: Apr 17 2004 10:21:09) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies C:\>php -r "var_dump(('0d1' == '0d2'));" bool(true) ------------------------------------------------------------------------ [2004-04-17 15:24:52] postings-php-bug at hans-spath dot de [Windows XP Pro SP1] D:\PHP>4.3.2\php-cli -r "var_dump(('0d1' == '0d2'));" bool(true) D:\PHP>4.3.3\php-cli -r "var_dump(('0d1' == '0d2'));" bool(true) D:\PHP>4.3.4\php-cli -r "var_dump(('0d1' == '0d2'));" bool(true) D:\PHP>4.3.6\php-cli -r "var_dump(('0d1' == '0d2'));" bool(true) D:\PHP>php4-win32-STABLE-latest\php-cli -r "var_dump(('0d1' == '0d2'));" bool(true) D:\PHP>php4-win32-STABLE-latest\php-cli -v PHP 4.3.7-dev (cli) (built: Apr 17 2004 14:18:37) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies [Linux 2.6.5] [EMAIL PROTECTED]:~/compile/php-4.3.6% sapi/cli/php -r "var_dump(('0d1' == '0d2'));" bool(false) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/28031 -- Edit this bug report at http://bugs.php.net/?id=28031&edit=1