|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-03-27 00:27 UTC] wayne at pruvodce dot cz
<?
if(strpos("bleble","ble",0)==false) echo("strpos has a bug!(1)\n");
if(strpos("bleble","ble",-1)==false) echo("strpos has a bug!(2)\n");
if(strpos("bleble","ble")==false) echo("strpos has a bug!(3)\n");
if(strpos("blebla","ble")==false) echo("strpos has a bug!(4)\n");
if(strpos("blable","ble")!=false) echo("now it works, weird ...\n");
if(strpos("xbleble","ble",0)!=false) echo("now it works, weird ...\n");
?>
(My friend found a bug in my template engine ... i'm pretty sure that this is the problem)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Jun 28 16:00:01 2026 UTC |
This is not a bug. strpos("bleble","ble") returns position 0 as it should. The way you are doing your check is incorrect. The condition 0 == false is true. You want to check for an empty string here "" to check to see if the string was not found. A 0 return is a match. Please see the user notes in the online manual. http://www.php.net/manual/function.strpos.php3