Last active
June 30, 2018 06:26
-
-
Save pwenzel/4567675 to your computer and use it in GitHub Desktop.
Get Current URL with PHP.
Inspired by CodeIgniter. Tested with Wordpress with and without fancy permalinks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_the_current_url() { | |
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"); | |
$base_url = $protocol . "://" . $_SERVER['HTTP_HOST']; | |
$complete_url = $base_url . $_SERVER["REQUEST_URI"]; | |
return $complete_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment