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. 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. 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()); Link to comment https://forums.phpfreaks.com/topic/71894-capturing-the-current-url/#findComment-362183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.