Neriokas Posted December 1, 2007 Share Posted December 1, 2007 Okay i have a very simple question, I'm kind of a noob in php + my english is 2nd language but ill try to explain this. how to get an url? <?php $url = url; echo $url; ?> how to get the url of the page that a person is on that moment at? Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/ Share on other sites More sharing options...
mlin Posted December 1, 2007 Share Posted December 1, 2007 $_SERVER['PHP_SELF'] Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-403795 Share on other sites More sharing options...
wsantos Posted December 1, 2007 Share Posted December 1, 2007 http://forums.devshed.com/php-development-5/server-php-self-or-something-similar-192694.html?p=833718 Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-403802 Share on other sites More sharing options...
nevesgodnroc Posted December 2, 2007 Share Posted December 2, 2007 Try this I had the same problems yesterday and i found this function it works great. function curPageURL() { $pageURL = 'http'; //Begins building Url if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} // checks to see if it is a secure page if so adds s $pageURL .= "://"; //adds next part of url if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; }else{ $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } // End Function curPageURL() Good luck Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-403957 Share on other sites More sharing options...
HaLo2FrEeEk Posted December 2, 2007 Share Posted December 2, 2007 Or you could use the super simple javascript: <script> var url = window.location.href; </script> Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-404049 Share on other sites More sharing options...
mlin Posted May 10, 2008 Share Posted May 10, 2008 $_SERVER['PHP_SELF'] will give you the current file plus any get vars in the uri to get the full uri, you would use: $_SERVER['REQUEST_URI'] I'd also recommend the function parse_url() to break it down into pieces for you. Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-537924 Share on other sites More sharing options...
alejojauregui Posted May 11, 2008 Share Posted May 11, 2008 I guess a URL can be got in many ways. You can get it for free from any space in internet, yahoo, google, etc. but also you can buy it in many other hosting services (there are many prices starting 2 dollar a month or so). It really depends what do you need the URL for. What languague is your primary? Okay i have a very simple question, I'm kind of a noob in php + my english is 2nd language but ill try to explain this. how to get an url? <?php $url = url; echo $url; ?> how to get the url of the page that a person is on that moment at? Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-537948 Share on other sites More sharing options...
Fadion Posted May 11, 2008 Share Posted May 11, 2008 I guess a URL can be got in many ways. You can get it for free from any space in internet, yahoo, google, etc. but also you can buy it in many other hosting services (there are many prices starting 2 dollar a month or so). It really depends what do you need the URL for. What languague is your primary? LOL hes not talking about getting a free/paid host, neither a domain name. He wants to get the current url by using php. And a URL (technically correct would be URI) is the address of the page, like www.yahoo.com, www.mysite.com/index.php etc. Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-537971 Share on other sites More sharing options...
HaLo2FrEeEk Posted May 11, 2008 Share Posted May 11, 2008 You know that's not what he meant, he meant getting the url of the current page, not buying a URL, don't be sarcastic. You must have known that, I mean, read your quote, he clearly said "how to get the url of the page that a person is on that moment", he must already have a webserver and a domain. Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-537972 Share on other sites More sharing options...
Fadion Posted May 11, 2008 Share Posted May 11, 2008 Its okay to be a newbie, take a look at topics to learn something and maybe post sometime if u feel u know that, but this guy ignored what everyone else wrote and went on giving advices on free hosts. Its practically nosense. Link to comment https://forums.phpfreaks.com/topic/79733-how-to-get-url/#findComment-537973 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.