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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 04:01:29 2025 UTC