Skip to content

Instantly share code, notes, and snippets.

@NoMan2000
Last active December 30, 2015 21:50
Show Gist options
  • Save NoMan2000/7889852 to your computer and use it in GitHub Desktop.
Save NoMan2000/7889852 to your computer and use it in GitHub Desktop.
Set document root folders.
<?php set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); ?>
<?php /* Another way of handling the same problem */
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/common/header.php";
include_once($path);
dirname(__FILE__);
?>
<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
function url(){
return sprintf(
"%s://%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
);
}
echo url();
?>
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment