php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #3633 strpos() reply ambigous
Submitted: 2000-02-26 08:18 UTC Modified: 2000-08-05 00:31 UTC
From: rb at odn dot de Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.14 OS: Linux 2.2.13 - glibc2.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: rb at odn dot de
New email:
PHP Version: OS:

 

 [2000-02-26 08:18 UTC] rb at odn dot de
Imagine the following small scriptlet:

$fd = fopen( $file, "r" );
$contents = fread( $fd, filesize( $file) );
fclose( $fd );
if (strpos($contents, "GIF87a")==0)
  {$kind="GIF87a";}
else
  {if (strpos($contents, "GIF89a")==0) 
     {$kind="GIF89a";}
   else 
     {if (strpos($contents, "JFIF")==6) 
        {$kind="JPEG";}
      else 
        {$kind="no_image";}}}
infobox("The uploaded file ($file_name) is $kind");

---

Problem is: strpos() returns 0 when either $contents starts with "GIF89a" or when "GIF89a" is not included in $contents at all.
Suggestion: start counting positions with one, or use other value for "false"?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-05 00:31 UTC] hholzgra@php.net
solved by php4's '===' operator
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 06:00:02 2026 UTC