How to use php pathinfo function?

青灯夜游
Release: 2023-02-22 22:28:02
Original
3038 people have browsed it

pathinfo() is a built-in function in PHP that returns information about the file path using an associative array or string. The syntax is pathinfo(path,options), which returns an associative array containing path information.

How to use php pathinfo function?

How to use the pathinfo() function?

The pathinfo function returns file path information in the form of an array.

Syntax:

pathinfo(path,options)
Copy after login

Parameters:The pathinfo() function accepts two 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 returns dirname.

●PATHINFO_BASENAME - Only basename is returned.

● PATHINFO_EXTENSION - only returns extension.

Return value:Returns an associative array containing path information. If the options parameter is not passed, include the following array elements: [dirname], [basename], [extension]

php pathinfo() function example

Copy after login

Output:

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

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:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!