1,105,636 Community Members

Retrieve URL from address bar

Member Avatar
mithesh
Newbie Poster
13 posts since Mar 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hi i want to read the whole URL passing through the address bar and asssign it to a variable .Please help me

Member Avatar
MitkOK
Junior Poster
142 posts since Jul 2007
Reputation Points: 61 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

URL of the current page :

$current_url = $_SERVER['REMOTE_ADDR'].$_SERVER['PHP_SELF'];

echo $current_url;

- Mitko Kostov

Member Avatar
MitkOK
Junior Poster
142 posts since Jul 2007
Reputation Points: 61 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

I was wrong posted the code above in a hurry.

You can use :

echo  'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; 

echo 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

echo 'http//'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

- Mitko Kostov

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article