if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) { //if ajax request your code runs here } else{ //if not an ajax request your code runs here }
Tag: PHP
To make cookies work globally on subdomains of a domain: setcookie('CookieName', 'Value', time() + 3600, '/', '.mydomain.com'); Note: remember to use the dot (.) in '.mydomain.com' not 'mydomain.com'
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
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
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>
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!= … Continue reading How to delete entire directory which is not empty in PHP