note 69992 added to function.image-type-to-extension

From: Date: Fri, 29 Sep 2006 02:55:10 +0000
Subject: note 69992 added to function.image-type-to-extension
Groups: php.notes 
Request: Send a blank email to php-notes+get-117814@lists.php.net to get a copy of this message
2006-09-29 A few notes about some contributions on this page. 1. It seemed to me that on the face it of all of the offerings to emulate "image_type_to_extension" function fell short of the mark in one way or another (See my comments below). That's why I wrote my own and submitted to this page below. In respect of my work any comments, bugs noted or improvements would be gratefully received. 2. Avoid using the Switch statement in an unconventional method to "Break" (I note the use of the return statement!). Also even if it does nothing at the inception of our code - Still put in the default case (It lets others realise that a default is not required or at worst forgotton. 3. In an environment that is under your control the risk of an error by determining the content by its extension or MIME type may seem an attractive solution to a problem. However, in the real world there's no guarantee that a MIME type or file extension is correct for it's associated file. Consider using functions to get the image type: getimagesize or (This is available without GD) exif_imagetype 4. There's more to coding than just putting something together to do a job!!! But whatever is done is worthwhile - Hence expletives have no place in this forum!! 5. The idea from "oridan at hotmail dot com" is a very slick idea. I will be taking a closer look at this for my own project. ---- Server IP: 83.138.144.80 Probable Submitter: 86.142.241.158 ---- Manual Page -- http://www.php.net/manual/en/function.image-type-to-extension.php Edit -- https://master.php.net/note/edit/69992 Del: integrated -- https://master.php.net/note/delete/69992/integrated Del: useless -- https://master.php.net/note/delete/69992/useless Del: bad code -- https://master.php.net/note/delete/69992/bad+code Del: spam -- https://master.php.net/note/delete/69992/spam Del: non-english -- https://master.php.net/note/delete/69992/non-english Del: in docs -- https://master.php.net/note/delete/69992/in+docs Del: other reasons-- https://master.php.net/note/delete/69992 Reject -- https://master.php.net/note/reject/69992 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117814) next »