Some PHP Tips: basename()

Here’s a quick tip: I’ve an absolute file path “/var/www/html/index.php”, but I need only the file name – index.php. So how do I get it?

basename

There it is:

$filename = basename('/var/www/html/index.php');

now $filename contains only “index.php”!

Leave a Reply

Your email address will not be published. Required fields are marked *