How to use Filesystem basename in PHP

In this article I am going to explain about basename function in PHP.
  • 1390

PHP basename() function

The filesystem  basename function is used to returns  the filename from a path.

Syntax of basename function

basename(path, suffix)

Parameters in basename function

It have two  parameter:

Parameter Description
path It specifies the path to check.
suffix It specifies a file extension.

Example of filesystem basename function

<html>

<body>

 

<?php

$path = "C:\wamp\www\Dinesh\mcn.txt";

 

echo "With file extension:";

echo basename($path) ."<br/>";

 

echo "Without file extension:";\

echo basename($path,".txt");

?>

 

</body>

</html>


Output:

basename function.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.