note 74381 deleted from function.basename by colder
| From: | colder@php.net | Date: | Sun, 08 Apr 2007 22:31:50 +0000 |
| Subject: | note 74381 deleted from function.basename by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125231@lists.php.net to get a copy of this message | ||
Note Submitter: bitagenda at gmail dot com
Reason: useless
----
Dealing with extension is not a matter of how to extract it at all, but how to identify an
extension.
It all depends on your application.
Why? Remember a filename could be
thisfile.isnamed.something
an another could be
this.file.isnamed.somehting.jpg
so, if you extract the first extension, it would be 'something', when it is not, it is
just part of the filename.
So before extracting an extension, check if your application is expecting an extension, which
commonly is a 3 to 4 characters, like in .htm, or .html, .jpg or .jpeg
So in practical terms, to get your extension or simple verification would be to check a possible
final period followed by 3 to 4 characters, to get an image type for example.
Many times it is enough to get the substr(dir,-4)