Bug #3633: strpos() reply ambigous
| From: | rb at odn dot de | Date: | Sat, 26 Feb 2000 13:18:46 +0000 |
| Subject: | Bug #3633: strpos() reply ambigous | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-16044@lists.php.net to get a copy of this message | ||
From: rb@odn.de
Operating system: Linux 2.2.13 - glibc2.1
PHP version: 3.0.14
PHP Bug Type: Feature/Change Request
Bug description: strpos() reply ambigous
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"?