Home > Backend Development > PHP Tutorial > How to use php pathinfo function

How to use php pathinfo function

藏色散人
Release: 2023-04-05 10:30:02
Original
4233 people have browsed it

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)
Copy after login

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)) ;
?>
Copy after login

Output:

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template