-retriving current page name-

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
wmasterh
Forum Newbie
Posts: 1
Joined: Thu Sep 19, 2002 8:57 am
Location: Stockholm, Sollentuna

-retriving current page name-

Post by wmasterh »

I am making a community and wonder if there s any function in PHP to retrive the name of the page wich is loaded:

Code: Select all

www.ed.ed/rf/tg/userVS.php?name=4fun
what I would like to be able to capture in a string i the:

Code: Select all

userVS.php?name=4fun
to able to add another variable later with something like:

Code: Select all

&id=3h4rk435o8u34545

I hope you can help me!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can use:

Code: Select all

$file_name =  basename($_SERVERї'PHP_SELF']);
to get the name of the current page.
It's also easy to add the query string information:

Code: Select all

$file_name_with_query_string = $file_name.'?'.$_SERVERї'QUERY_STRING'];
Mac
User avatar
~J~R~R
Forum Newbie
Posts: 20
Joined: Wed Sep 18, 2002 12:19 pm
Location: Amsterdam, the Netherlanda

Post by ~J~R~R »

Code: Select all

$url = array_pop(explode('/', $_SERVERї'PHP_SELF']));
I think that's it.

[edit]i think twigletmac is located closer to the server than i[/edit]
Post Reply