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? Quote Link to comment Share on other sites More sharing options...
mlin Posted December 1, 2007 Share Posted December 1, 2007 $_SERVER['PHP_SELF'] Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.