[wp-hackers] PHP one liner
steve at de-generationx.net
Tue Dec 14 11:47:59 UTC 2004
> Here's a quick bit of code to get the filename out of a URL/path:
> Given $_SERVER['PHP_SELF'] == '/some/dir/index.php'
> <?php $page = array_pop( explode( '/', $_SERVER['PHP_SELF'] ) ); ?>
> $page will contain the 'index.php', no regexs, no fuss.
This is a good way of doing it, however with the viral nature of
mod_rewrite spreading everywhere, I personally do it using
I did it this way in my pathfinder() function that gets used for
navigation on most chunks of my site. For the very fact that using
PHP_SELF did not work if the path you wanted was really the mod_rewrite
version. You can view the full code for my pathfinder() code at the
More information about the hackers