PHP 4.0 Bug #7763: strrpos returns unclear value
| From: | timo at fi-web dot de | Date: | Sat, 11 Nov 2000 23:49:46 +0000 |
| Subject: | PHP 4.0 Bug #7763: strrpos returns unclear value | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-37784@lists.php.net to get a copy of this message | ||
From: timo@fi-web.de
Operating system: Linux
PHP version: 4.0.3pl1
PHP Bug Type: Unknown/Other Function
Bug description: strrpos returns unclear value
The following code doesn't work as expected:
$haystack = "/test";
$needle = "/";
$position = strrpos($haystack, $needle);
if ($position == false) { echo "Couldn't find $needle"; }
It seems that strrpos returns false, even if the position of the needle was 0 (It is the first
position in the string, isn't it?). strrpos should return 0 if the needle was found in haystack
at position 0 and FALSE if the needle wasn't found. Additionally, strrpos also returns 0 if the
needle wasn't found in haystack. Maybe FALSE and 0 are defined as the same in that context?
IMHO, 0 and FALSE should be defined different, or strrpos should NOT return a value (like unset) if
the needle wasn't found in haystack.
Regards
Timo
--
Edit Bug report at: http://bugs.php.net/?id=7763&edit=1