1 path.inc current_path()

Return the current URL path of the page being viewed.

Examples:

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

request_path()

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'];
  }
}