This function returns a filename without the path.

Syntax: basename ( path ,suffix )

The first Parameter “path” is Required. It Specifies the path to be check.

The second Parameter “suffix” is Optional.It Specifies a file extension. If the filename has this file extension, the file extension will not show

Strips a filename from path and suffix.

The basename() function returns a filename without the path. If the suffix parameter is provided, it will also be removed.

Example:
Code:

$filename = "D:\wamp\www\sadique\session_name.php";
echo "$filename
"; echo basename($filename) . "
"; echo basename($filename, ".php") . "
"; echo basename($filename, "_name.php");

Output:

D:\wamp\www\sadique\session_name.php
session_name.php
session_name
session

Explanation:

Explanation:

The above code shows how basename() can be used to modify a filename.

eXTReMe Tracker