Same name and namespace in other branches
  1. 4.7.x includes/common.inc \base_path()
  2. 5.x includes/common.inc \base_path()
  3. 6.x includes/common.inc \base_path()
  4. 7.x includes/common.inc \base_path()
  5. 8.9.x core/includes/common.inc \base_path()
  6. 9 core/includes/common.inc \base_path()

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

Function 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:

39 calls to base_path()
AttachedAssetsTest::testAggregation in core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php
Integration test for CSS/JS aggregation.
BigPipePlaceholderTestCases::cases in core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipePlaceholderTestCases.php
Gets all BigPipe placeholder test cases.
BigPipeTest::testNoJsDetection in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe's no-JS detection.
BlockContentCreationTest::testBlockContentFormSubmitHandlers in core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
Tests the redirect workflow of creating a block_content and block.
BlockContextualLinksTest::testBlockContextualRemoveLinks in core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php
Test to ensure that remove contextual link is present in the block.

... See full list

15 string references to 'base_path'
AlreadyInstalledException::__construct in core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
Constructs a new "already installed" exception.
FieldPluginBaseTest.php in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
FileMigrationSetupTrait::fileMigrationSetup in core/modules/file/tests/src/Kernel/Migrate/d7/FileMigrationSetupTrait.php
Prepare the file migration for running.
FollowUpMigrationsTest::getFileMigrationInfo in core/modules/migrate_drupal/tests/src/Kernel/d7/FollowUpMigrationsTest.php
Returns information about the file to be migrated.
HtmlToTextTest::setUp in core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php

... See full list

File

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

Code

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