How do I create a php page that has access to the Drupal API? I would like to create a PHP page that executes Drupal API functions.

The page would be inside my Drupal 7 website, perhaps the theme directory, but I'm not sure where it should reside.

I would like this page to run a query to the database using the Drupal's database abstraction layer. Once the query is retrieved, I would like to run some other D7 API functions and finally print out a page.

The page should not be one of the default Drupal templates, but a new page, that simply has one single  within it.

How can I achieve this?

EDIT: The correct way to do this is to implement hook_menu() inside a module. I'm trying to do this, but my approach doesn't work. This is what I'm doing:


the profileBox.info file



name = PB
description = "Creates a callback to returnuid.tpl.php"
package = SDNN
core = 7.x
files[] = profileBox.module



the profileBox.module file is installed and has the following code:




function profileBox_menu() {
  $items['returnunid'] = array(
    'title'=&gt;'Example'
    'description'=&gt;'examples'
    'page callback' =&gt; 'profileBoxGetit',
    'access callback'=&gt;TRUE,
  );

  return $items;
}

function profileBoxGetit() {
  $stringit = "the string output";

  return $stringit;
}



I created a returnuid.tpl.php file with some html code in it - just to test (not functional code)
I then pointed my browser to [root]/?q=returnuid
I expected to get the content of the $stringit variable, but I instead got an "access denied" error


This module actually messes up the Administration menu, which dissapears when the module is installed.

What am I doing wrong?
The correct way to "create a PHP page that executes Drupal API functions" is to create a module.

In that module, you implement hook_menu() which allows you to tell Drupal that it should call a given php function for a specific path, for example 'yourmodule/somepath'. Inside that, you can then execute whatever PHP and Drupal API functions which you want.

See http://drupal.org/node/1074360 for more information.