getting filename


#1

I try this code to get the filename

echo $_SERVER[‘PHP_SELF’];

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

/login.php

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

thanks for any help.


#2

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.


#3

You could also use, str_replace()

[php]

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

[/php]


#4

Thanks for all you help. It works.


#5

What about basename() ?