What does the pathinfo() function do?
In PHP, the pathinfo() function is used to return file path information in the form of an array. His syntax is as follows:
Grammar
pathinfo(path,options)
Parameter details:
Parameter | Description |
---|---|
path | Required. Specifies the path to be checked. |
process_sections | Optional. Specifies the array elements to be returned. The default is all. Possible values:
|
[basename]:Return the file name part of the file path
[extension]:Return the type part of the file in the file path
Example
Example 1, use the pathinfo() function to obtain all file path information, the code is as follows<?php print_r(pathinfo("/testweb/test.txt")); ?>
[filename]: is the file name of the php file
Example 2, use the pathinfo() function to obtain individual PATHINFO_BASENAME information, the code is as follows :<?php print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME)); ?>
The above is the detailed content of Detailed explanation of php pathinfo() function to obtain file path information. For more information, please follow other related articles on the PHP Chinese website!