Home  >  Article  >  Backend Development  >  How to use php pathinfo function

How to use php pathinfo function

藏色散人
藏色散人Original
2019-02-19 15:57:304168browse

php pathinfo function usage: Return file path information in the form of an array. The syntax is "pathinfo(path, options)". The parameter path is required and refers to the path to be checked.

How to use php pathinfo function

php The pathinfo() function is used to return file path information in the form of an array. Its syntax is pathinfo(path, options). The parameter path is required and refers to Specifies the path to be checked.

How to use php pathinfo function?

php pathinfo() function Syntax

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

Syntax:

pathinfo(path,options)

Parameters:

path required. Specifies the path to be checked.

process_sections Optional. 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. Including the following array elements: [dirname], [basename], [extension]

php pathinfo() function usage example

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

Output:

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

This article is an introduction to the PHP pathinfo function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php pathinfo function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn