Get the URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

Get the URL

Post by paladaxar »

Ok here's the deal:

I want to be able to echo $URL where $URL is the URL of the page that is echoing it 8O . um...in other words...if I was at ebay.com...I would want to assign "http://www.ebay.com" to the variable $URL. Is this possible?
sticksys
Forum Commoner
Posts: 33
Joined: Thu Aug 18, 2005 3:23 am
Location: Isreal
Contact:

Post by sticksys »

i not thing i understand but try this:

echo $_SERVER['PHP_SELF'];


maybe this is what you need :|
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

Post by paladaxar »

well...thats really close. Is there any command that will list any variables also? For example "http://www.lala.com/a_folder/mypage.php?catagory=food". Is there any way to get that ENTIRE string? The command listed above would return "a_folder/mypage.php"
The Monkey
Forum Contributor
Posts: 168
Joined: Tue Mar 09, 2004 9:05 am
Location: Arkansas, USA

Post by The Monkey »

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

throw up

Code: Select all

echo '<pre>';
print_r($_SERVER);
echo '</pre>';
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I guess this is wot you are looking for.

Code: Select all

echo $_SERVER['REQUEST_URI']."<br />";
or

Code: Select all

print_r($_GET);
or

Code: Select all

foreach($_GET as $key => $value){
	echo $key."-".$value."<br />";
}
User avatar
Fractal
Forum Commoner
Posts: 54
Joined: Tue Aug 16, 2005 1:28 pm

Post by Fractal »

I think $PHPSELF does aswell o_O
Post Reply