Page 1 of 1

-retriving current page name-

Posted: Thu Sep 19, 2002 8:57 am
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!

Posted: Thu Sep 19, 2002 9:05 am
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

Posted: Thu Sep 19, 2002 9:05 am
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]