Page 1 of 1

What is "my" url?

Posted: Wed Sep 04, 2002 12:45 pm
by ealhajj
How do I get the url string of the current .php page? For example:

I am writing a page "hello.php" that resides on http://www.webserver.com. I want to display the url string "www.webserver.com/hello.php". How do I get that string?

Thanks,
ealhajj

Posted: Wed Sep 04, 2002 1:04 pm
by PaTTeR

Code: Select all

<?php
echo $_SERVER&#1111;SERVER_NAME].$_SERVER&#1111;PHP_SELF];
?>
This is ... but take a look at
http://www.php.net/manual/en/reserved.v ... les.server
:wink:

Posted: Thu Sep 05, 2002 4:24 am
by twigletmac
If you don't want PHP to have to do extra work looking for constants named SERVER_NAME and PHP_SELF try:

Code: Select all

echo $_SERVER&#1111;'SERVER_NAME'].$_SERVER&#1111;'PHP_SELF'];
and to view the contents of the $_SERVER array:

Code: Select all

echo '&lt;pre&gt;';
print_r($_SERVER);
echo '&lt;/pre&gt;';
Mac

Posted: Thu Sep 05, 2002 2:02 pm
by phice
Oh yes, the sexy $DOCUMENT_ROOT is used alot in my stuff. :D