It's been a while since I've wanted to use stand-alone PHP files and call drupal from those files. There are two cleaner ways to do such a thing:
- create 'page' nodes with PHP input format
- create a module and define the hook_menu() callback
- Doesn't require space in the database -- free PHP-enabled hosting providers seem to have small database quotas independent of your filesystem quota.
- Uses the filesystem to lookup what code to run for a certain URL. This is likely to be faster than a Drupal path alias lookup in the database.
- Every enabled module uses up memory on every page view, so if you can avoid creating a module by using php files, your PHP processes will have a smaller memory footprint, possibly making your web server faster or able to handle more users.
The way I'm doing it is something like:
<?php
chdir('/full/path/to/top/drupal/directory/');
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// so that drupal_is_front_page() returns false, and probably other reasons
$_GET['q'] = 'fake';
// call other drupal functions like drupal_set_title() or drupal_set_breadcrumb() here if you like
echo theme('page', 'the HTML contents of your page go here');
