The base URL of the Drupal installation.
See also
File
- developer/
globals.php, line 22 - These are the global variables that Drupal uses.
Code
<?php
global $base_url
?>
Login or register to post commentsThe base URL of the Drupal installation.
<?php
global $base_url
?>
Login or register to post comments
Comments
[From the D6 API
[From the D6 API comments:]
Base URL will begin with https:// if the current page is being accessed through the HTTPS protocol. This depends on the availability of $_SERVER['HTTPS'] which may not be available if a reverse proxy or load balancer is in use.
Also, the $base_url does not include the trailing slash, like so:
http://www.example.comIf you're using the $base_url to construct a link, make sure you add the trailing slash, like so:
<?php$link = $base_url . '/node/add';
?>
Includes path
If Drupal is in a subdirectory, it includes the path to the subdirectory when follows
global $base_url;access through $GLOBALS array
<?php$link = $GLOBALS['base_url'] . '/node/' . $node->nid;
?>
as with any super global variable you can access through $GLOBALS array.
here is a link to a node id.
Consider using l()
As a side note, creating a link to a node is better done with l(). This example will not work on a site with clean URLs turned off.