|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-08-05 00:31 UTC] hholzgra@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Jun 17 05:00:01 2026 UTC |
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"?