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
What is "my" url?
Moderator: General Moderators
Code: Select all
<?php
echo $_SERVERїSERVER_NAME].$_SERVERїPHP_SELF];
?>http://www.php.net/manual/en/reserved.v ... les.server
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you don't want PHP to have to do extra work looking for constants named SERVER_NAME and PHP_SELF try:
and to view the contents of the $_SERVER array:
Mac
Code: Select all
echo $_SERVERї'SERVER_NAME'].$_SERVERї'PHP_SELF'];Code: Select all
echo '<pre>';
print_r($_SERVER);
echo '</pre>';