Skip to content

Instantly share code, notes, and snippets.

@oleteacher
Last active December 14, 2018 12:51
Show Gist options
  • Save oleteacher/899f07149ef573a82e5effb229c9d2ba to your computer and use it in GitHub Desktop.
Save oleteacher/899f07149ef573a82e5effb229c9d2ba to your computer and use it in GitHub Desktop.
Function to get full server URL to directory
<?php
function url_part(){
$http=isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$part=rtrim($_SERVER['SCRIPT_NAME'],basename($_SERVER['SCRIPT_NAME']));
$domain=$_SERVER['SERVER_NAME'];
return "$http"."$domain"."$part";
}
?>
<?php echo url_part(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment