ID: 15691 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Closed Bug Type: Feature/Change Request Operating System: Any PHP Version: 4.1.1 New Comment:
I think returning -1 would be much worse. That would mean that if(strpos($str,"foo")) would evaluate to true when "foo" does not exist in $str. Bad idea. What has been suggested is to have it start at 1 instead of 0 to indicate a match in the first position. That is a better idea, except it is inconsistent with the rest of PHP. String indices start at 0 and often the result of a strpos() is passed to substr() in which case starting the strpos() return at 1 would really confuse people. The way it currently is implemented is the most consistent and least confusing in my opinion. Previous Comments: ------------------------------------------------------------------------ [2002-02-23 15:23:02] [EMAIL PROTECTED] Changing this behavior will break way too many scripts, so it's absolutely not a good idea to change this behavior. Derick ------------------------------------------------------------------------ [2002-02-23 15:12:51] [EMAIL PROTECTED] It would be boundlessly helpful if someone could make strpos(), etc. return a -1 instead of FALSE like C++/Java. Returning a FALSE (something that casts to an integer of 0) doesn't seem to make much sense. Even if it can be worked around with strpos() === FALSE, it would be a lot easier without having to rely upon it. Any reason why it should be using FALSE instead of -1? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15691&edit=1
