note 51084 added to function.strstr
| From: | robbie | Date: | Sat, 19 Mar 2005 01:07:18 +0000 |
| Subject: | note 51084 added to function.strstr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86673@lists.php.net to get a copy of this message | ||
With regard to the below comment
<?php
$filename = "funnypicture.jpg";
$type = str_replace('.','',strstr($filename, '.'));
echo $type; // jpg
?>
This gets the file extension into the variable $type, not the file type.
To get the file type, use filetype(), or to get the MIME content type, use mime_content_type().
<?php
$filename = "funnypicture.jpg";
$ext = str_replace('.','',strstr($filename, '.'));
$type = filetype($filename);
$mime = mime_content_type($filename);
echo $ext; // jpg
echo $type; // file
echo $mime; // image/jpeg
?>
----
Manual Page -- http://www.php.net/manual/en/function.strstr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51084
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51084&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51084&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51084&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51084&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51084&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51084&report=yes
Search -- http://master.php.net/manage/user-notes.php