How to find out what page I am on?

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
matt1019
Forum Contributor
Posts: 172
Joined: Thu Jul 06, 2006 6:41 pm

How to find out what page I am on?

Post by matt1019 »

Hi guys,

Sorry if the subject/title is a little vague...

Here's my question:

If I want to find out what page I am on and the page uses "=" as in http://www.mysite.com/index.php?user=512

then I can say:

Code: Select all

if(isset(user))
{
echo "user id is $user";
}
but how do I find what page I am on, based on the address only (without "?user=" part) as in http://www.mysite.com/view/photos.php

viewing page: photos

example two: http://www.mysite.com/interact/chat.php

viewing page: chat

see what I am saying?
Bascially, with the above format, I CANNOT use isset.... so I cannot find out what page I am on.

Is there any way to do this BESIDES using cookies?
(any php method?)

thanks for your help guys,

-Matt
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

$_SERVER['PHP_SELF']
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

forum search term: geturl
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

basename()

Code: Select all

<?php
$thispage = basename(__FILE__, '.php');
?>
matt1019
Forum Contributor
Posts: 172
Joined: Thu Jul 06, 2006 6:41 pm

Post by matt1019 »

Thanks Guys,

Worked out! I used Everah's technique ;)

And also thanks to feyd and Burrito for their efforts!


Regards,

-Matt
Post Reply