exif_imagetype and constant confusion

From: Date: Fri, 21 Dec 2007 21:59:05 +0000
Subject: exif_imagetype and constant confusion
Groups: php.general 
Request: Send a blank email to php-general+get-275654@lists.php.net to get a copy of this message
Stupid question time! I can't find my answer anywhere, sorry about this... The nature of the return value of exif_imagetype() is baffling me. The php manual uses one simple example like this: <code> <?php if (exif_imagetype('image.gif') != IMAGETYPE_GIF) { echo 'The picture is not a gif'; } ?> </code> okay, cool. the return value is the constant IMAGETYPE_GIF. of course if you do something like this: <code> $foo = exif_imagetype('image.jpg'); echo $foo; </code> you'll echo out 2. Great, seems really useful to me. What am I missing? Why is the value of the IMAGETYPE_XXX constants an integer, for one thing, and not a string like 'gif' or 'jpg'? And how do I access some sort of usable string telling me the type of image without having to do something retarded like putting a bunch of strings in a numerically indexed array (which will be completely confusing later when I try to figure it out). And thirdly, what the !?#@ am I missing here? I feel like an idiot, but it makes no sense to me that an 'imagetype' function would return something that evaluates to an integer. Please help, my head hurts. Thanks ec

« previous php.general (#275654) next »