fetching current pagename

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
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

fetching current pagename

Post by itsmani1 »

here is url:
http://127.0.0.1/atlantared/admin/adminhome.php
I am on above url page
now i want to fetch current page name? how i can do so, mean i want to fetch adminhome.php form this

http://127.0.0.1/atlantared/admin/adminhome.php?ab=12
will this method also apply on 2nd url or not? if not how can i use it for 2nd URL
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

check your $_SERVER superglobal array :)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

shiznatix wrote:check your $_SERVER superglobal array :)
how can i access this array
By using :

$_SERVER['......']
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

yes exactally.

to view this array do

Code: Select all

echo '<pre>';
print_r($_SERVER);
echo '</pre>';
then find what you are looking for and use it just like you would use the $_POST array, $_GET array, or a regular array.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Thanks much.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Code: Select all

basename($_SERVER['PHP_SELF'])
Post Reply