How can I call a Drupal function or get the global variable in a PHP file which is located under the drupal installation folder. I doing it for the first time. Are there any files I need to include in my code in order to access the Drupal function or variables?
Taken from the linked question in the comment above
You need to Bootstrap Drupal in the external PHP file:
/** bootstrap Drupal **/
chdir("/path/to/drupal/site/htdocs");
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Be sure to change the path to your Drupal installation, then add your code below the code posted above.