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.

@todo The above comment is incorrect: http://drupal.org/node/1547294.

8 calls to request_uri()
DbLogTest::generateLogEntries in drupal/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
Generates a number of random database log events.
DbLogTest::testDBLogAddAndClear in drupal/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
Tests the addition and clearing of log events through the admin interface.
drupal_page_get_cache in drupal/core/includes/bootstrap.inc
Retrieves the current page from the cache.
drupal_render_cid_parts in drupal/core/includes/common.inc
Returns cache ID parts for building a cache ID.
drupal_settings_initialize in drupal/core/includes/bootstrap.inc
Sets the base URL, cookie domain, and session name from configuration.

... See full list

File

drupal/core/includes/bootstrap.inc, line 1454
Functions that need to be loaded on every Drupal request.

Code

function request_uri($omit_query_string = FALSE) {
  if (isset($_SERVER['REQUEST_URI'])) {
    $uri = $_SERVER['REQUEST_URI'];
  }
  else {
    if (isset($_SERVER['argv'][0])) {
      $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 $omit_query_string ? strtok($uri, '?') : $uri;
}