Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to write a utility method to print redirect in PHP?

$
0
0
  1. function redirect($uri='',$method='location', $http_response_code=302){
  2.  
  3.   if(!preg_match('#^https?://#i',$uri)){
  4.         $uri= BASE_URL .$uri;
  5.     }
  6. switch($method){
  7.  case'refresh':header("Refresh:0;url=".$uri);
  8.         break;
  9.  default:header("Location: ".$uri,TRUE,$http_response_code);
  10.       break;
  11.  }
  12.  exit;
  13. }

Viewing all articles
Browse latest Browse all 178

Trending Articles