語法
pathinfo(path,options)
參數 | 描述 |
---|---|
path | 必需。規定要檢查的路徑。 |
process_sections |
可選。規定要返回的數組元素。默認是all。 可能的值:
|
例子 1
<?php
print_r(pathinfo("/testweb/test.txt"));
?>
輸出:
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
例子 2
<?php
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
輸出:
test.txt
例子 3
<?php
$path_parts = pathinfo('/www/htdocs/inc/lib.inc.php');
echo $path_parts['dirname'], "\n";
echo $path_parts['basename'], "\n";
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n"; // since PHP 5.2.0
?>
輸出:
/www/htdocs/inc
lib.inc.php
php
lib.inc
全站熱搜
留言列表