Current Location: Home> Function Categories> pathinfo

pathinfo

Returns the file path information
Name:pathinfo
Category:File system
Programming Language:php
One-line Description:Returns information about file paths.

Definition and usage

pathinfo() function returns the information about the file path as an array.

Example

Example 1

 <?php
print_r ( pathinfo ( "/testweb/test.txt" ) ) ;
?>

Output:

 Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)

Example 2

 <?php
print_r ( pathinfo ( "/testweb/test.txt" , PATHINFO_BASENAME ) ) ;
?>

Output:

 test.txt

grammar

 pathinfo ( path , options )
parameter describe
path Required. Specify the path to be checked.
process_sections

Optional. Specifies the array element to be returned. The default is all.

Possible values:

  • PATHINFO_DIRNAME - Return only dirname
  • PATHINFO_BASENAME - Return only basename
  • PATHINFO_EXTENSION - Return only extension

illustrate

pathinfo() returns an associative array containing path information.

Includes the following array elements:

  • [dirname]
  • [basename]
  • [extension]
Similar Functions
Popular Articles