note 90706 deleted from reserved.variables.server by thiago
| From: | thiago@php.net | Date: | Tue, 05 May 2009 16:09:28 +0000 |
| Subject: | note 90706 deleted from reserved.variables.server by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154242@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
I absolutely can NOT understand why there is no
$_SERVER["BASE_URL"] available.
Use this code:
<?php
// returns "http://hostname/basedirectory/"
public static function GetBaseUrl()
{
if (stripos($_SERVER["SERVER_PROTOCOL"], "https") === 0)
$Protocol = "https://";
else
$Protocol = "http://";
return $Protocol . $_SERVER['HTTP_HOST'].
dirname($_SERVER['PHP_SELF'])."/";
}
?>