getting filename


I try this code to get the filename

echo $_SERVER[‘PHP_SELF’];

and it did return the filename but it look like this:


how could I get the filename without the slash before it?

thanks for any help.


Try this:

[php]$self = substr($_SERVER[‘PHP_SELF’], 1, (strlen($_SERVER[‘PHP_SELF’]) - 1));[/php]

That should basically take the length of PHP_SELF and then throw out the first character.


You could also use, str_replace()


<? echo str_replace("/","",$_SERVER['PHP_SELF']); //Will give you: login.php ?>



Thanks for all you help. It works.


What about basename() ?