1 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/backdrop_folder/node/306 returns "node/306" while base_path() returns "/backdrop_folder/".
- http://example.com/url-alias (which is a URL alias for node/306) returns "node/306" as opposed to the URL 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 backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL) makes this function available.
Return value
The current Backdrop URL path. The path is untrusted user input and must be: treated as such.
See also
File
- core/
includes/ path.inc, line 338 - Functions to handle paths in Backdrop, including URL aliasing.
Code
function current_path() {
if (isset($_GET['q'])) {
return $_GET['q'];
}
}