Skip to content

Instantly share code, notes, and snippets.

@PizzaLiu
Last active December 17, 2015 00:49
Show Gist options
  • Save PizzaLiu/5523982 to your computer and use it in GitHub Desktop.
Save PizzaLiu/5523982 to your computer and use it in GitHub Desktop.
function pheader($string,$exit=true,$replace = true, $http_response_code = 0) {
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$string = str_replace(array("\r", "\n"), array('', ''), $string);
if(empty($http_response_code) || PHP_VERSION < '4.3' ) {
@header("Location: http://$host$uri/$string", $replace);
} else {
@header("Location: http://$host$uri/$string", $replace, $http_response_code);
}
if($exit) {
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment