Quick post: sometimes you (or someone you are working with) may need to break out from Drupal, and generate a special page perhaps based on some existing php code that has been adapted or similar, but that is now pulling data from drupal.
The following code is a brief example of an approach that allows foo.php (in this example) to have full access to any to any variables you may create from querying Drupal and perhaps pick up arguments from the url. foo.php in this case is now responsible for generating the page output.
The use of drupal_exit(); in this case still allow modules to implement exit hooks.
/** * Implements hook_menu() */ function my_module_menu() { $items = array(); $items['foo'] = array( 'title' => t("Foo"), 'type' => MENU_NORMAL_ITEM, 'page callback' => 'my_module_foo_page', 'page arguments' => array(), ); return $items; } /** * My module foo page callback */ function my_module_foo_page($arg1 = false, $arg2 = false, $arg3 = false) { //do some regular Drupal stuff here, populate some variable etc. drupal_add_http_header('Content-Type','text/html'); include_once('foo.php'); drupal_exit(); }