PHP

Posts related to PHP

PHP double quotes vs single quotes

Strings in PHP can be specified in four different ways: single quoted, double quoted, heredoc syntax and (since PHP 5.3.0) nowdoc syntax, the first two of them being by far the most frequently used. It is important to know the difference between using single quotes and double quotes. In this post we will see the …

PHP double quotes vs single quotes Read More »

Get search query string from search engines using PHP

I have often come across situations when I would like to implement some functionality based on what the user searched for in a search engine like Google, Bing etc. The search query string is normally passed as GET variables ‘q’ or ‘query’. The function below will return the search query string. Note: Google has recently …

Get search query string from search engines using PHP Read More »

PHP isset() vs empty() vs is_null()

PHP has different functions which can be used to test the value of a variable. Three useful functions for this are isset(), empty() and is_null(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results. isset() and empty() are often viewed as functions that …

PHP isset() vs empty() vs is_null() Read More »

Getting real client IP address in PHP

Many times we need the visitor’s ipaddress for validation, security, spam prevention, etc. Getting the Visitor’s ipaddress is very easy in PHP. The simplest way to get the visitor’s/client’s ipaddress is using the $_SERVER[‘REMOTE_ADDR’] or $_SERVER[‘REMOTE_HOST’] variables. The variable in the $_SERVER array are created by the web server (like apache) and we can use …

Getting real client IP address in PHP Read More »

Voting Functionality in a website

In this post I will give the step by step explanation of how we can add Voting Functionality to a website. At the end of this article we will have a working sample voting application. The source code for the sample voting application can be downloaded from here. We will be using PHP, MySQL, jQuery, …

Voting Functionality in a website Read More »