Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP basename() Function

PHP basename() Function


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual


Definition and Usage

The basename() function returns the file name part of a path.

Syntax

basename(path,suffix)

Parameters Description
path Required. Specifies the path to check.
suffix Optional. Specifies a file extension. If the file has that file extension, it will not be shown.

Example

"; //Show filename without file extension echo basename($path,".php"); ?>

The code above will output:

home.php

home


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual