note 74381 added to function.basename

From: Date: Sun, 08 Apr 2007 21:17:48 +0000
Subject: note 74381 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-125226@lists.php.net to get a copy of this message
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) ---- Server IP: 69.147.83.197 Probable Submitter: 216.62.70.35 ---- Manual Page -- http://www.php.net/manual/en/function.basename.php Edit -- https://master.php.net/note/edit/74381 Del: integrated -- https://master.php.net/note/delete/74381/integrated Del: useless -- https://master.php.net/note/delete/74381/useless Del: bad code -- https://master.php.net/note/delete/74381/bad+code Del: spam -- https://master.php.net/note/delete/74381/spam Del: non-english -- https://master.php.net/note/delete/74381/non-english Del: in docs -- https://master.php.net/note/delete/74381/in+docs Del: other reasons-- https://master.php.net/note/delete/74381 Reject -- https://master.php.net/note/reject/74381 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125226) next »