php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5537 problem with value false returning from strpos() function
Submitted: 2000-07-12 18:30 UTC Modified: 2000-07-12 18:47 UTC
From: sat at 3wdesign dot es Assigned:
Status: Closed Package: Other
PHP Version: 4.0.0 OS: Linux Debian 2.1
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sat at 3wdesign dot es
New email:
PHP Version: OS:

 

 [2000-07-12 18:30 UTC] sat at 3wdesign dot es
<?
$string = "FOO STRING";
$string1 = "FOO";
$string2 = "OO";
$string3 = "ZOO";

$value1 = strpos($string,$string1,0);
$value2 = strpos($string,$string2,0);
$value3 = strpos($string,$string3,0);

for ($i=1;$i<=3;$i++) {
   if (${value.$i}>=0) {
      echo "string".$i." found at:".${value.$i}."<br>"; 
      }
   elseif (${value.$i}==FALSE) { 
      echo "string".$i." not found.<br>"; 
      }
}

?>

$value3>=0    and  $value3==FALSE   are equivalent  and so we can not distinguish between string found at position 0 and string not found.

strpos should return -1 when the string was not found.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-12 18:47 UTC] eschmid at cvs dot php dot net
Closed on user request.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 04:01:28 2024 UTC