function current_path
current_path()
Return the current URL path of the page being viewed.
Examples:
- http://example.com/node/306 returns "node/306".
- http://example.com/drupalfolder/node/306 returns "node/306" while base_path() returns "/drupalfolder/".
- http://example.com/path/alias (which is a path alias for node/306) returns "node/306" as opposed to the path alias.
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
File
- includes/path.inc, line 355
- Functions to handle paths in Drupal, including path aliasing.
Code
function current_path() { return $_GET['q']; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!path.inc/function/current_path/7.x