php pathinfo() function


  Translation results:

Return file path information

php pathinfo() functionsyntax

Function: Return file path information in the form of an array.

Syntax: pathinfo(path,options)

Parameters:

ParameterDescription
path Required. Specifies the path to be checked.
process_sectionsOptional. Specifies the array elements to be returned. The default is all. Possible values: PATHINFO_DIRNAME - only dirname is returned. PATHINFO_BASENAME - only basename is returned. PATHINFO_EXTENSION - only extension is returned.

Description: Returns an associative array containing path information. Includes the following array elements: [dirname], [basename], [extension]

php pathinfo() functionexample

<?php
$file = "/phpstudy/WWW/index.php";
print_r(pathinfo($file)) ;
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [dirname] => /phpstudy/WWW [basename] => index.php [extension] => php [filename] => index )

Home

Videos

Q&A