Bug #14774 [Com]: strpos with strtolower to working incorrectly
| From: | aledmb at gmail dot com | Date: | Sat, 29 Jun 2013 02:15:52 +0000 |
| Subject: | Bug #14774 [Com]: strpos with strtolower to working incorrectly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179960@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=14774&edit=1
ID: 14774
Comment by: aledmb at gmail dot com
Reported by: armtuk at yahoo dot com
Summary: strpos with strtolower to working incorrectly
Status: Not a bug
Type: Bug
Package: Strings related
Operating System: Linux 2.4.9-7smp
PHP Version: 4.0.6
Block user comment: N
Private report: N
New Comment:
please ignore my previous comment, i'm dumb... should be checking for false, as
zero is a valid offset.
Previous Comments:
------------------------------------------------------------------------
[2013-06-29 02:10:51] aledmb at gmail dot com
strpos has a bug.
the following statement should give 1, but gives zero:
echo strpos(strtolower('C'), 'c');
------------------------------------------------------------------------
[2001-12-30 10:54:04] georg@php.net
Sorry, but it works correct.
In your sample $query has no "insert", therefore strpos
returns 0 (not found), as desribed in the manual.
------------------------------------------------------------------------
[2001-12-30 10:50:04] mfischer@php.net
Thats the documented and expected behaviour.
------------------------------------------------------------------------
[2001-12-30 10:45:00] armtuk at yahoo dot com
<?php
$query="insert into users (user_name) values 'user_name'";
if (strpos(strtolower($query),"select")==0)
{
print "FISH!";
}
?>
Amazingly enough this prints FISH!.
but:
$query="insert into users (user_name) values 'user_name'";
if
(strpos(strtolower($query),"select")==0&&!(strpos(strtolower($query,"select")===FALSE))
{
print "FISH!";
}
does not.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=14774&edit=1