Log in

View Full Version : retrieve url (simple problem)



james438
01-13-2008, 07:15 AM
Hi,

Just wondering how I can get the url of the page that a script is running on. for example if page http://www.mysite/test.php were to be executed the output would be the text: http://www.mysite/test.php.

thanks

james438
01-13-2008, 09:41 AM
Found it the answer just now. The following will print the relative url:
<?php
print $_SERVER['REQUEST_URI'];
?>
The following will display the complete url:

<?php
print $_SERVER['SCRIPT_URI'];
?>
The following will give you all the info that you need:

<?php
print var_dump($_SERVER);
?>