ID: 30399 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: Documentation problem PHP Version: 4.3.9 New Comment:
Already documented. Previous Comments: ------------------------------------------------------------------------ [2004-10-12 10:15:46] [EMAIL PROTECTED] "Is === operator equal to strcmp() if two arguments are strings with numbers in the beginning?" They are equivalent AFAIK. "Many coders use "==" instead of "strcmp" and there should be warning somewhere in manual about possible problems that could arise due to such misuse." There is "If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers. These rules also apply to the switch statement." in language.operators.comparison. I think this bug can be marked as bogus. ------------------------------------------------------------------------ [2004-10-11 17:40:57] [EMAIL PROTECTED] Description: ------------ After studying some string issues I think we need one more page in manual about strings comparison with a link to/from strcmp. Few confusing examples from user-notes on http://www.php.net/manual/en/language.types.string.php And I haven't found any clear answer about is === operator equal to strcmp() if two arguments are strings with numbers in the beginning? Many coders use "==" instead of "strcmp" and there should be warning somewhere in manual about possible problems that could arise due to such misuse. See also: http://bugs.php.net/bug.php?id=28200 Reproduce code: --------------- <?php $x1 = '111111111111111111'; $x2 = '111111111111111112'; echo ($x1 == $x2) ? "true\n" : "false\n"; //true ?> <? $hello='hi there'; echo($hello?'true':'false'); //true echo($hello==0?'true':'false'); //true!!!!! echo($hello===0?'true':'false'); //false ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30399&edit=1