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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-05 00:31 UTC] hholzgra@php.net
solved by php4's '===' operator
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 14:01:32 2024 UTC