Create Tiny URL Link With PHP Function

Tiny URL site allows you to compress the size of your URLs which is mostly used on the social networking site twitter, because of the limited characters you can use. But to use the tiny URL feature yo...

PHP Code to Combine and Compress CSS

A couple of Google updates ago they worked on page loading speeds, so if your page loaded faster then your website will be ranked higher. Easy ways to improve on your website speed is: Reduce the siz...

PHP Password Generator Snippet

Get stuck trying to pick a new password each time you signup to a new service or website. Most people do use the same password on every site that they go to but this can be dangerous if 1 site gets ha...

Force download of files in PHP

If you have files on your website that you want people to download you need to change the code to allow the browser to automatically download the file. This is because if you had an image on your webs...

Compress multiple CSS Files

If you are using multiple CSS files on a large website sometimes they can take along time to long the best way to deal with this is to compress the CSS by removing all comments and spaces in the file....

Convert Seconds to Time in PHP

Here is useful function to convert seconds to a time either years, months, days or hours. function Sec2Time($time){ if(is_numeric($time)){ $value = array( "years" => 0, "days" =&am...

Calculate distances in PHP

Here is a code snippet which allows you to calculate the distance between longitude and latitudes in either miles, kilometres or nautical miles. function distance($lat1, $lon1, $lat2, $lon2, $unit) {...

Easily cache pages with PHP

If you are not using a CMS or a framework you may need to cache your pages to speed up the page loading times. This can easily be done in PHP using the ob functions. OB Function In PHP ob_start() ob_...

Speed up Page Load by reducing HTTP requests with PHP

A nice technique to speed up your page loading times is to try to reduce the amount of calls your browsers has to make to the server. This will be every image, every css and every JavaScript file incl...

Using cURL in PHP

PHP/CURL is a binding that uses libcurl. It means that the PHP team has written a glue layer for PHP that speaks to the underlying libcurl. That layer, the binding, is what we call PHP/CURL and that i...

Remove Whitespace and line breaks in String

In any programming language there is a simple in-built function you can use to remove whitespace from a string the main one used will be a string replace to search for spaces and replace with empty. I...

PHP Delete Directory and Files In Directory

In PHP if you want to delete a directory there is security against deleting a directory which has files in it. Therefore you need to delete all the files in the folder before you can delete the direct...