PHP pathinfo() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The pathinfo() function returns information about a file path as an array.
The returned array elements are as follows:
Syntax
pathinfo(path,options)
| Parameters | Description |
|---|---|
| path | Required. Specifies the path to check. |
| options | Optional. Specifies the array element to return. Default is all.
Possible values: |
Tips and Notes
**Note:** If not all elements are requested, pathinfo() returns a string.
Example
Example 1
The code above will output:
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
[filename] => test
)
Example 2
The code above will output:
test.txt