I'm making a menu page which will be included into every main page on my site. The idea is, the current page will only be text in the menu, while the rest of the pages will be links in the menu. So all I need is a command to get the current page's filename. The code goes something like this:
<?php
if (!filename("index.php")) {
print ("<a href=index.php>"); }
print ("Index</a> :: ");
?>
Where !filename would be ![command]. It's probably really simple. ;p Anyone?
Using page's filename
Moderator: General Moderators
Code: Select all
if(eregi("index.php",$REQUEST_URI)) {
echo "Index";
} else {
echo "<a href="index.php">Index</a>";
}Following script will print the current file's name:-
Simple...
Code: Select all
<?php
echo $PHP_SELF;
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
And if you happen to have register globals off (which is the default now), you could use:
(Use $HTTP_SERVER_VARS instead of $_SERVER if you have PHP 4.0.6)
Mac
Code: Select all
$_SERVERї'PHP_SELF']
$_SERVERї'REQUEST_URI']
$_SERVERї'SCRIPT_NAME']Mac
-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm