Skip to content

Instantly share code, notes, and snippets.

@nameDark
Last active September 13, 2016 10:41
Show Gist options
  • Save nameDark/e9db68dc6c99a5f28c542b6e699773a5 to your computer and use it in GitHub Desktop.
Save nameDark/e9db68dc6c99a5f28c542b6e699773a5 to your computer and use it in GitHub Desktop.
get current URL
<?php
// get current URL
function get_current_URL() {
$current_url = 'http';
$server_https = $_SERVER["HTTPS"];
$server_name = $_SERVER["SERVER_NAME"];
$server_port = $_SERVER["SERVER_PORT"];
$request_uri = $_SERVER["REQUEST_URI"];
if ($server_https == "on") $current_url .= "s";
$current_url .= "://";
if ($server_port != "80") $current_url .= $server_name . ":" . $server_port . $request_uri;
else $current_url .= $server_name . $request_uri;
return $current_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment