function request_uri

Returns the equivalent of Apache's $_SERVER['REQUEST_URI'] variable.

Because $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.

9 calls to request_uri()
drupal_deliver_html_page in includes/common.inc
Packages and sends the result of a page callback to the browser as HTML.
drupal_fast_404 in includes/bootstrap.inc
Returns a simple 404 Not Found page.
drupal_page_get_cache in includes/bootstrap.inc
Retrieves the current page from the cache.
drupal_page_set_cache in includes/common.inc
Stores the current page in the cache.
drupal_render_cid_parts in includes/common.inc
Returns cache ID parts for building a cache ID.

... See full list

File

includes/bootstrap.inc, line 1954

Code

function request_uri() {
  if (isset($_SERVER['REQUEST_URI'])) {
    $uri = $_SERVER['REQUEST_URI'];
  }
  else {
    if (isset($_SERVER['argv'])) {
      $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
    }
    elseif (isset($_SERVER['QUERY_STRING'])) {
      $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
    }
    else {
      $uri = $_SERVER['SCRIPT_NAME'];
    }
  }
  // Prevent multiple slashes to avoid cross site requests via the Form API.
  $uri = '/' . ltrim($uri, '/');
  return $uri;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.