function current_path

Return the current URL path of the page being viewed.


This function is not available in hook_boot() so use $_GET['q'] instead. However, be careful when doing that because in the case of Example #3 $_GET['q'] will contain "path/alias". If "node/306" is needed, calling drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) makes this function available.

Return value

The current Drupal URL path. The path is untrusted user input and must be treated as such.

See also


14 calls to current_path()
common_test_init in modules/simpletest/tests/common_test.module
Implements hook_init().
drupal_cache_system_paths in includes/
Cache system paths for a page.
drupal_goto in includes/
Sends the user to a different page.
drupal_lookup_path in includes/
Given an alias, return its Drupal system URL if one exists. Given a Drupal system URL return one of its aliases if such a one exists. Otherwise, return FALSE.
drupal_redirect_form in includes/
Redirects the user to a URL after a form has been processed.

... See full list


includes/, line 355


function current_path() {
    return $_GET['q'];

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