Home >Backend Development >PHP Tutorial >PHP's very useful advanced functions PATH_SEPARATOR constant and set_include_path
pathinfo(path,options)ParametersDescription
path | Required. Specifies the path to be checked. |
---|---|
process_sections | Optional. Specifies the array elements to be returned. The default is all. |
PATHINFO_DIRNAME - only returns dirname PATHINFO_BASENAME - only returns basename PATHINFO_EXTENSION - only returns extension
| pathinfo() Returns an associative array containing
Includes the following array elements:
[dirname]
[basename][extension]Example
Example 1
<?php print_r(pathinfo("/testweb/test.txt")); ?>Output:
Array ( [dirname] => /testweb [basename] => test.txt [extension] => txt )
Example 2
<?php print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME)); ?>
Output:
test.txt
DIRECTORY_SEPARATOR window below
Instructionswindows
linux
The above has introduced PHP's very useful advanced functions PATH_SEPARATOR constant and set_include_path, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.