Pages

Your Ad Here

This Blog is not to read or go through

because, I have never been such a mess


Search the blog instead

Friday, April 16, 2010

Automatic Base URL in PHP

# Generate the BASE_URL

$request = $_SERVER["REQUEST_URI"];
$script_path = $_SERVER["SCRIPT_NAME"];
$base_url_len = strlen($script_path) - strlen("index.php");
$arg = explode("/", substr($request, $base_url_len));
$base_url = "http://". $_SERVER["HTTP_HOST"] . substr($script_path, 0, $base_url_len);
define("BASE_URL", $base_url);

author -- acpmasquerade

No comments:

Your Ad Here