Bug #12676: strpos() ignores first character in haystack
| From: | aragon at phat dot za dot net | Date: | Thu, 09 Aug 2001 19:22:19 +0000 |
| Subject: | Bug #12676: strpos() ignores first character in haystack | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-62729@lists.php.net to get a copy of this message | ||
From: aragon@phat.za.net
Operating system: FreeBSD 4.3
PHP version: 4.0.6
PHP Bug Type: Scripting Engine problem
Bug description: strpos() ignores first character in haystack
When performing a string search with strpos() on a string variable the
function totally ignores the first character. For example:
$astring = "abc defg hij kl";
if (strpos($astring, "abc")) {
echo("found\n");
} else {
echo("not found\n");
}
When running the above script "not found" is echoed instead when, in fact,
"found" should be echoed. Here's my ./configure from phpinfo():
./configure' '--with-config-file-path=/usr/local/etc/php.standalone'
'--disable-pear' '--enable-versioning' '--with-system-regex'
'--disable-debug' '--enable-track-vars' '--without-gd'
'--without-mysql'
'--with-zlib' '--with-mysql=/usr/local' '--enable-ftp'
'--with-curl=/usr/local' '--enable-sockets' '--prefix=/usr/local'
'i386--freebsd4.3'
A possible workaround would be:
$astring = "abc defg hij kl";
$astring = " " . $astring;
if (strpos($astring, "abc")) {
echo("found\n");
} else {
echo("not found\n");
}
The above code echoes "found".
Regards,
Aragon Gouveia
--
Edit bug report at: http://bugs.php.net/?id=12676&edit=1