From The Blog

PHP: check whether an AJAX request

5 June 2013, in

if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {


//if ajax request your code runs here



//if not an ajax request your code runs here


Post a Comment

PHP: make the cookies work globally on all subdomains

2 January 2013, in

To make cookies work globally on subdomains of a domain:

setcookie('CookieName', 'Value', time() + 3600, '/', '');

remember to use the dot (.) in '' not ''

Post a Comment

CakePHP and MySQL tinyint datatype

21 September 2012, in

I observed that CakePHP treats tinyint fields as boolean (true/false) , but after investigation found that:

if you set the data type for a field to tinyint with length of 1, then CakePHP will treat it as boolean.

So I changed it to tinyint(2),

That's weird about CakePHP

Post a Comment

Installing PHP5 and Apache on Ubuntu

20 June 2012, in

First, you'll want to add the extra repositories to Ubuntu's sources.list file.

From a command shell, you will run the following commands:

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

Post a Comment

install mysql server 5 on ubuntu

20 June 2012, in

Open a terminal window, and use the following command:

sudo apt-get install mysql-server

If you are running PHP you will also need to install the php module for mysql 5:

sudo apt-get install php5-mysql

To create a new database, use the mysqladmin command:

mysqladmin create <databasename>

Post a Comment

How to delete entire directory which is not empty in PHP

8 May 2012, in

In PHP to delete a file we use unlink() function,

and to delete a directory we use rmdir() function but the directory has to be empty first

Here is how to delete the entire directory whether it has files or not

function delete_directory($path){

$d = dir($path);

while($entry = $d->read()) {

if ($entry!= "." && $entry!= "..") {











Post a Comment