PHP Functions
These are a few of the many PHP functions I have developed and use on a regular basis. Most of these functions are skeletons, and need to be adapted for a specific use. Most functions also contain comments which make the code easy to understand. I do not mind if you borrow any of these functions, provided that you both ask permission and credit me in your code. All files are in PDF format.
- Form Skeleton - This file is a skeleton of an html form. The form is self-submitting, contains validation and processing functions, and provides error feedback. The form is not formatted for display purposes, and does nothing, but it provides an example of the different types of inputs (save for an image upload, which you can find in my image_upload.php file). This skeleton serves as the basis for the majority of forms I create.
- Get Browser Type - This function returns the user's browser type. It is especially useful in cases where browsers interpret standards differently. The browsers that it detects include: Mozilla, IE, Gecko, Firefox, Konqueror, Safari, Netscape, Navigator, Opera, Mosaic, Lynx, Amaya, and Omniweb.
- Image Functions - Currently only contains 1 image function, which is resize_image. The function is given a source and destination image name, a maximum dimension (width or height), and jpeg quality. The source image is resized, according the maximum dimension, maintaining the proper aspect ratio. It is also resampled, and compressed according to the provided jpeg quality. This function is great for creating thumbnails.
- MySQL Sample Functions - This file contains sample functions which use my mySQL wrapper functions. Functions included in this file are:
- get_next_key()
- insert_row()
- sort_and_list_entries()
- list_entries()
- filter_and_list_entries()
- update_row($key)
- delete_row($key)
- delete_filtered_rows()
- MySQL Wrapper Functions - Contains wrappers I wrote around the built in PHP functions. These wrapper functions simplify calls to a mySQL database. Instead of having to connect, select a database, and then query it, you are able to make 1 call which does everything for you.
- File & Directory Functions - Contains the following functions:
- get_last_file_mod($root) - Returns the timestamp of the last file modified in the $root directory and all subdirectories. This differs from the built in getlastmod() function because it searches ALL files, including images, word docs, text files, and every other file you may have on the server. This is useful in returning the TRUE last time the website was modified.
- find_files($search,$dir) - Returns an array of files found that match the search parameters. $search is the filename to search for, and can contain wildcards. $dir is the directory that is to be searched. This function does not search subdirectories.
- Upload Image Form - Contains necessary html syntax for uploading a file via a form. The function save_images() will save a jpeg image if the uploaded image type is image/jpeg. This function can be adapted to save multiple files from the same form, and can be used with the resize_image() function to upload an image and create a thumbnail of the image automatically when it is uploaded.