How to access Drupal functions and sesions in a stand alone PHP script
If you want to access Drupal functions and sessions in your stand alone PHP scripts which is present any where in your project directory then how you will do this?
Let say you are going to create one websevices in drupal thats mean you have to create one PHP stand alone file then how you will access the Drupal functions?
First of all I am clearing this that this solution is for Drupal 7, not sure this will work in Drupal 6 or not, as I have not tested this in Drupal 6 environment.
Below are the code you have to write in you PHP stand alone file.
$path = getcwd();
$pos = strpos($path, 'sites');
$path = substr($path, 0, $pos);
$path = explode('\\', $path);
$length = sizeof($path);
unset($path[$length - 1]);
$path = implode('/', $path);
// Get the base path
//Include the bootstrap file for using the DRUPLA function in our file
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
Now you can access any function of Drupal 7 in this stand alone PHP file