|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14774 strpos with strtolower to working incorrectly
Submitted: 2001-12-30 10:45 UTC Modified: 2001-12-30 17:59 UTC
From: armtuk at yahoo dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.0.6 OS: Linux 2.4.9-7smp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: armtuk at yahoo dot com
New email:
PHP Version: OS:


 [2001-12-30 10:45 UTC] armtuk at yahoo dot com

$query="insert into users (user_name) values 'user_name'";

if (strpos(strtolower($query),"select")==0)
   print "FISH!";


Amazingly enough this prints FISH!.


$query="insert into users (user_name) values 'user_name'";

   print "FISH!";

does not.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-30 10:50 UTC]
Thats the documented and expected behaviour.
 [2001-12-30 10:54 UTC]
Sorry, but it works correct.

In your sample $query has no "insert", therefore strpos 
returns 0 (not found), as desribed in the manual.

 [2013-06-29 02:10 UTC] aledmb at gmail dot com
strpos has a bug.

the following statement should give 1, but gives zero:

echo strpos(strtolower('C'), 'c');
 [2013-06-29 02:15 UTC] aledmb at gmail dot com
please ignore my previous comment, i'm dumb... should be checking for false, as 
zero is a valid offset.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 20:01:30 2024 UTC