ID: 43218 Updated by: [EMAIL PROTECTED] Reported By: kkitts at clearviewcatv dot net -Status: Open +Status: Bogus Bug Type: Strings related Operating System: Windows XP SP2 PHP Version: 5.2.4 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. if(strripos($str, "pineapple", 0) !== false) You can do type comparison to check this. Previous Comments: ------------------------------------------------------------------------ [2007-11-08 17:21:03] kkitts at clearviewcatv dot net Description: ------------ This may or may not be a bug, but it is very inconvenient. stripos returns the location of string1 within string2. If it doesn't find string1 within string2, it returns false. This works well, unless string1 is found at position 0 (the first character of the string). In this case, it returns the position of string1 in string2, which happens to be 0. This is also the value of the "FALSE" definition. So, when I have code like below, the echo statement never gets executed because the if() function thinks 0 == FALSE. I'm still trying to think of a manual workaround. Possible fix: rewrite stripos to have optional 4th parameter specifying an alternate return value if string1 isn't found in string2 (such as stripos($str, "pineapple", 0, -1), which would return -1 instead of FALSE). Reproduce code: --------------- $str = "pineapple"; if(strripos($str, "pineapple", 0)) { echo "Comments cannot contain \"pineapple\".<br/>"; } Expected result: ---------------- Comments cannot contain "pineapple". Actual result: -------------- (nothing) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43218&edit=1