Vectorials
Flash Perfection
3D Lessons
Tutorialkit
Markup Tutorials
Learn PHP
network
adv banner
Web Programming  Home Web Programming PHP Image Class: Function getExtension
rss

Image Class: Function getExtension

Author: Nathanael Mitchell More by this author


function getExtension($filename){
$dot = substr (strrchr ($filename, "."), 1);
return $dot;
}

This is a very small, simple fucntion. it returns the file extension of a given file (in jpg format; with no .). All I use this for is the resize function. If you try to resize a .pdf file, you will get an error, so I have this check to make sure the file extension is ok. you can also call this function outsite of the resize function like this:

$ext = $obj_images->getExtension("./test/img.jpg");
echo $ext;

Thats really all there is for the function, you see how we use it in the rezise function in the next section. Sooo, next function:



Rate this Material: Bad 1 2 3 4 5 Excellent
print this page tell a friend subscribe to newsletter subscribe to rss

Add comments to "Image Class: Function getExtension"