SCook Posted October 5, 2007 Share Posted October 5, 2007 I know there's a way to do this, but it slips my mind. Is there a way to get the current url? Something other than $PHP_SELF? Because php self only returns the current file, I need the whole thing, from http: onward. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/71894-capturing-the-current-url/ Share on other sites More sharing options...
trq Posted October 5, 2007 Share Posted October 5, 2007 Take a look at the $_SERVER array here. You might try concatinating $_SERVER['REQUEST_URI'] and $_SERVER['QUERY_STRING'] together. Quote Link to comment https://forums.phpfreaks.com/topic/71894-capturing-the-current-url/#findComment-362172 Share on other sites More sharing options...
DBookatay Posted October 5, 2007 Share Posted October 5, 2007 I use this code: function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } $URL = (selfURL()); Quote Link to comment https://forums.phpfreaks.com/topic/71894-capturing-the-current-url/#findComment-362183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.