getting the name of the requested page from an included page

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
@modi
Forum Newbie
Posts: 3
Joined: Sun Mar 18, 2007 11:18 pm

getting the name of the requested page from an included page

Post by @modi »

If you have one page that includes another, is there a way for the included file to access the name of the first page when it is requested? For example:

index.php:

Code: Select all

<?php include_once("navigation.php");?>
...
navigation.php:

Code: Select all

You requested page: <?php echo $requested_page?>.
Is there a way to make $requested_page contain the value "index.php" when navigation.php is included from index.php?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you can define $requested_page in index.php
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

Look at this page http://www.php.net/get_included_files, specially comments by keystorm :at: gmail dotcom
Post Reply