Current Location: Home> Function Categories> basename

basename

Returns the file name part in the path
Name:basename
Category:File system
Programming Language:php
One-line Description:Returns the file name part in the path.

Definition and usage

basename() function returns the file name part in the path.

Example

 <?php
$path = "/testweb/home.php" ;

//Show filename with file extension
echo basename ( $path ) ;

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

Output:

 home.php
home

grammar

 basename ( path , suffix )
parameter describe
path Required. Specify the path to be checked.
suffix Optional. Specify file extensions. If the file has suffix, this extension will not be output.
Similar Functions
  • Returns the file path information pathinfo

    pathinfo

    Returnsthefilepathin
  • Obtain file permissions fileperms

    fileperms

    Obtainfilepermission
  • Export buffered content to file fflush

    fflush

    Exportbufferedconten
  • Determine whether the given file name is writable is_writable

    is_writable

    Determinewhethertheg
  • Get the file owner fileowner

    fileowner

    Getthefileowner
  • Give information about a file or symbol connection lstat

    lstat

    Giveinformationabout
  • Create a hard connection link

    link

    Createahardconnectio
  • Get information about a connection linkinfo

    linkinfo

    Getinformationabouta
Popular Articles