Last active
January 23, 2019 09:57
-
-
Save FuruholmAnton/5643a8252f15fd6c58d5bdef48c05dcd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function get_current_url($strip = true) { | |
// filter function | |
static $filter; | |
if ($filter == null) { | |
$filter = function($input) use($strip) { | |
$input = str_ireplace(array( | |
"\0", '%00', "\x0a", '%0a', "\x1a", '%1a'), '', urldecode($input)); | |
if ($strip) { | |
$input = strip_tags($input); | |
} | |
// or any encoding you use instead of utf-8 | |
$input = htmlspecialchars($input, ENT_QUOTES, 'utf-8'); | |
return trim($input); | |
}; | |
} | |
return 'http'. (($_SERVER['SERVER_PORT'] == '443') ? 's' : '') | |
.'://'. $_SERVER['SERVER_NAME'] . $filter($_SERVER['REQUEST_URI']); | |
} |
This file contains hidden or 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 | |
static function url(){ | |
return sprintf( | |
"%s://%s%s", | |
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', | |
$_SERVER['HTTP_HOST'], | |
$_SERVER['REQUEST_URI'] | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment