954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Retrieve URL from address bar

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

mithesh
Newbie Poster
13 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

URL of the current page :

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

echo $current_url;


-Mitko Kostov

MitkOK
Junior Poster
142 posts since Jul 2007
Reputation Points: 59
Solved Threads: 12
 

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

MitkOK
Junior Poster
142 posts since Jul 2007
Reputation Points: 59
Solved Threads: 12
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You