Get The File Extension In PHP

Getting a file extensions from a PHP string is an important task on validating a file for a upload. For example if you have a file uploader which you only want to use for image uploads then you need...

Parse URL Querystring Into Array In PHP

Using query strings in PHP is a good way of transferring data from one file to another. This is done by using the $_GET variable. This variable is a global variable that is used to get the content of...

Get Current URL With PHP

Use the below PHP snippet to construct the current page URL. It will find out if the URL is on a secure URL or not, gets the server name and port number if needed and the current page. function...

Easily Create A Table In PHP

Here is a small PHP snippet to easily create a table in PHP. First create the draw_table function.

Create A Weather Application With Google API Using PHP

As of August 2013 Google shut down it's weather API. The following tutorial will not work with the Google weather API but you can use the following code for another weather API that you find. ![Wea...

Display Message To Stumbleupon Visitors In PHP

Stumbleupon is a great way of getting lots of visitors to your site. All you have to do is submit your pages to Stumbleupon and when people stumble in their chosen topic they will find your page. The...

Display Gravatar From Email Address

In a previous article you learnt how you can display the the author avatar in Wordpress. But if you aren't using Wordpress then you will need to use a Gravatar. ## Gravatar A Gravatar is your image t...

How To Create A URL Slug With PHP

Having a user friendly URL is user important not just for SEO but also to help the visitors know that the website they are on is correct. If you have spaces in your URL they will be replaced by %20 s...

Use PHP To Detect An Ajax Request

Here is a quick PHP snippet that you can use to tell if the request coming to the page is from a form or from an Ajax request. Where a page is being accessed by AJAX it will post data using XML, PHP c...

How To 301 Redirect With PHP

Search engines index pages by the URL of the page, if these pages are moved to a different URL then the search engines will have indexed a page that no longer exists. Therefore people search in the s...

Use PHP To Get The Real IP Address

If you want to record the visitors IP Address there are a few things you need to remember, computers on shared internet connections can have different IP Addresses and visitors coming to your website...

PHP __get And __set Magic Methods

PHP is a loosely typed programming language, one of the features of a loosely typed language is that you can use variables without declaring them or their type. In other languages such as c# you need...

PHP Magic Method __toString()

During OOP in PHP you need to debug the class, you can use the var_dump method but this isn't so user friendly, so you need an alternative to the var_dump(); PHP have released some magic method which...

Increase The Default Maximum File Upload Size In PHP

If you have a website which allows users to upload their own images then you will need to change the default maximum files size upload. The PHP default for all file uploads is 2MB, so the server will...

Using Static Methods In PHP

A static method allows us to use the method without creating the object first. This means that we can use the scope resolution operator :: to use the method. Static methods can not be accessed by usin...