Newbie question - finding the request URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ashikuzzaman
Forum Newbie
Posts: 5
Joined: Mon Jun 23, 2003 6:22 am
Location: Dhaka, Bangladesh
Contact:

Newbie question - finding the request URL

Post by Ashikuzzaman »

I am a newbie in PHP.

In PHP, How do I find the URL of the page I am searching? Is it something in header()? I want that my PHP page knows its URL and prints in the footer the name of the page. Ot is the any request object in PHP, from where I can extract the requested page's name?

Please help. :(
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Check the output of:

Code: Select all

echo '<pre>';
print_r($_SERVER);
echo '</pre>';
Possibly you need something like $_SERVER['PHP_SELF']?

Mac
Ashikuzzaman
Forum Newbie
Posts: 5
Joined: Mon Jun 23, 2003 6:22 am
Location: Dhaka, Bangladesh
Contact:

thanks

Post by Ashikuzzaman »

Thank you very much. Its working. I can use either $_SERVER['PHP_SELF'] OR $_SERVER['SCRIPT_NAME'] .

One more help please. :D

What's the name of the function that can be used to cut a subsring from a string or that finds a character (say dot or slash) from a string?

Actually what I want to do is to cut the word links from the URL /mysite/links.php . :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You could use str_replace().

Mac
Post Reply