| 7 path.inc | current_path() |
| 8 path.inc | 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.
See also
11 calls to current_path()
File
- includes/
path.inc, line 354 - Functions to handle paths in Drupal, including path aliasing.
Code
function current_path() {
return $_GET['q'];
}
Login or register to post comments
Comments
without language prefix
Will also return URLs without the language prefix.