note 51084 deleted from function.strstr by thiago
| From: | thiago@php.net | Date: | Tue, 28 Oct 2008 13:48:13 +0000 |
| Subject: | note 51084 deleted from function.strstr by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145874@lists.php.net to get a copy of this message | ||
Note Submitter: robbie [at] averill [dot] co [dot] nz
----
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
?>