Page 1 of 1
Using page's filename
Posted: Tue Sep 10, 2002 5:52 pm
by Bennettman
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?
Posted: Tue Sep 10, 2002 7:20 pm
by dusty
Code: Select all
if(eregi("index.php",$REQUEST_URI)) {
echo "Index";
} else {
echo "<a href="index.php">Index</a>";
}
Posted: Wed Sep 11, 2002 1:11 am
by Takuma
Following script will print the current file's name:-
Simple...
Posted: Wed Sep 11, 2002 1:25 am
by dusty
$PHP_SELF could replace $REQUEST_URI, but either way I'd still use eregi to check for the match. $PHP_SELF prints /'s
You could also use $SCRIPT_NAME.. all would pretty much do the same thing.
Posted: Wed Sep 11, 2002 2:24 am
by twigletmac
And if you happen to have register globals off (which is the default now), you could use:
Code: Select all
$_SERVERї'PHP_SELF']
$_SERVERї'REQUEST_URI']
$_SERVERї'SCRIPT_NAME']
(Use $HTTP_SERVER_VARS instead of $_SERVER if you have PHP 4.0.6)
Mac
Posted: Wed Sep 11, 2002 2:53 pm
by Bennettman
Thanks a lot! It worked with $PHP_SELF.