in reply to Rewrite a PHP fileExtension function
The cookbook/File::Basename is definitely the way to go. The other two (including the PHP one) have bugs. Well, the same bug: you're lower-casing the extention, which means you're going to end up with a different extention than the original file. That'll make it quite painful to put the filename parts back together again to reach the original file.
"txt" ne "TxT"
If you need the lowercased version of the extention, for example in trying to guess at the mime type, you should do that outside of a function of "extention". Perhaps in the function named "guess_mimetype" it would make sense.
|
|---|