Jump to content

How to get url?


Neriokas

Recommended Posts

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
Share on other sites

  • 5 months later...

$_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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.