tribulant

current_url

Oct 3rd, 2012
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. function current_url() {       
  2.         $currentUrl = (($_SERVER['HTTPS'] != "on") ? 'http://' : 'https://');
  3.         $currentUrl .= $_SERVER['HTTP_HOST'];
  4.         //$currentUrl .= ($_SERVER['SERVER_PORT'] != "80") ? ':' . $_SERVER['SERVER_PORT'] : '';
  5.         $currentUrl .= $_SERVER['REQUEST_URI'];
  6.         $currentUrl .= (!empty($_SERVER['QUERY_STRING']) && !preg_match("/(\?)/i", $_SERVER['REQUEST_URI'])) ? '?' . $_SERVER['QUERY_STRING'] : '';    
  7.         return $currentUrl;
  8.     }
Advertisement
Add Comment
Please, Sign In to add comment