PHP pathinfo() Function

PHP pathinfo Function


Definition :

In this tutorial we have to learned about PHP pathinfo() Function.The pathinfo() Function is inbuilt funciton in php.This function return about a file path : either an associative array or a string, depending on flags.

Syntax

  pathinfo(pathoptions)

Parameter 
Parameter Description
path Required. Specifies the path to be checked
options Optional. Specifies which array element to return. If not specified, it returns all elements.

Possible values:

  • PATHINFO_DIRNAME - return only dirname
  • PATHINFO_BASENAME - return only basename
  • PATHINFO_EXTENSION - return only extension
  • PATHINFO_FILENAME - return only filename

Given below example shows the usage of pathinfo() function:

Output :