English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The pathinfo() function can return an array containing information about the path. If options are specified, it will return the specified elements; they include: PATHINFO_DIRNAME, PATHINFO_BASENAME, and PATHINFO_EXTENSION or PATHINFO_FILENAME. If no options are specified, it defaults to returning all elements.
mixed pathinfo ( string $path [, int $options = PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME ] )
The pathinfo() function can return information about the path: an associative array or a string, depending on the options.
<?php print_r(pathinfo("/PhpProject/simple.txt")); ?>
Output Result
Array ( [dirname] => /PhpProject1 [basename] => simple.txt [extension] => txt [filename] => simple )
<?php print_r(pathinfo("/PhpProject/simple.txt, PATHINFO_BASENAME)); ?>
Output Result
simple.txt