PHPのパス情報()関数
定義と使用法
パス情報()関数は、ファイルパスに関する情報の配列を返します。
次のように返される配列の要素は以下のとおりです。
- [DIRNAME]
- [ベース名]
- [拡張機能]
文法
pathinfo(path,options)
参数 | 描述 |
---|---|
path | 必需。规定要检查的路径。 |
options | 可选。规定要返回的数组元素。默认是 all。 可能的值:
|
ヒントと注意事項
注:いないすべてのリクエストの要素の、パス情報()関数は、文字列を返す場合。
例1
<?php
print_r(pathinfo("/testweb/test.txt"));
?>
print_r(pathinfo("/testweb/test.txt"));
?>
意志出力上のコード:
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
例2
<?php
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
意志出力上のコード:
test.txt
PHPファイルシステムリファレンスマニュアルを完了