Making Functions Re-usable (PHP Example)…

Some how i been involved in creating few parts of http://www.hottdogzzbikinizz.com 😉 . well i know what ya thinking , but its not like that *grin grin*…

One of the features i Developed was the JPG upload function [did’nt involve Mysql] … what simply happens when you first submit the form it will check if you did’nt forget any field . It will also check wether the submitted image is a JPEG/PJPEG otherwise it wont accept it …

the 2nd step is to process the uploaded image , Creates a folder with name-age-location of the submiter and stores the images in it.

3rd step is to send an email to the admin with all the user details , Image Location , and the actual Location( by ip ) of the submitter .

almost 300 lines of code ….

now lets see one of the examples : imagine we want to create a folder for every user using his Name Age and Location assuming we already extracted the posted values into variables …

$name $age $loc

$success = mkdir($name."-".$age."-".$loc,0777) if(!$success) {

exit(‘something went wronge’); }

this is ok , but what if i want to use the above code more than 100 times ?! Copy & Paste …. ? No ..