W3cubDocs

/Drupal 8

function base_path

base_path()

Returns the base URL path (i.e., directory) of the Drupal installation.

base_path() adds a "/" to the beginning and end of the returned path if the path is not empty. At the very least, this will return "/".

Examples:

File

core/includes/common.inc, line 413
Common functions that many Drupal modules will need to reference.

Code

function base_path() {
  return $GLOBALS['base_path'];
}

© 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/core!includes!common.inc/function/base_path/8.1.x