Say you have http://example.com/drupal/documentation?page=1
. Let's presume documentation
is an alias for node/26419
Then after a full bootstrap
$GLOBALS['base_url'] | http://example.com/drupal |
base_path() | /drupal/ |
request_uri() | /drupal/documentation?page=1 |
request_path() | documentation |
current_path() | node/26419 |
Note that base_path() is a one line wrapper for returning the global $base_path and similarly current_path() just returns $_GET['q']. Unlike in previous versions of Drupal, the 'q' variable is not loaded by .htaccess but computed during bootstrap and so the old method of reading $_REQUEST['q'] for the original path does not work in Drupal 7, use request_path() instead.
Pay attention to slashes on the bases: base_url never has a slash at the end while base_path always has one.
Finally note that before the full bootstrap (hook_boot, cache backends and other early plugins) the current_path() function doesn't exist and $_GET['q'] is still 'documentation'. The rest is set up extremely early so those can be relied upon.
Commenting on this Story is closed.
This looks like a Drupal certification question
This is helpful; thanks! How does arg() factor in here?
it's explode('/', $_GET['q']) and current_path is return $_GET['q'].