pathinfo() 関数は、パスに関する情報を含む配列を返します。
次の配列要素が返されます:
pathinfo(path,options)
パラメータ | 説明 |
---|---|
path | 必須。チェックするパスを指定する |
options | 任意。返す配列要素を指定する:デフォルトは全てを返す。
指定可能な値:
|
注: pathinfo() 関数は、すべての要素を要求しない場合は文字列を返します。
<?php
print_r(pathinfo("/testweb/test.txt"));
?>
上のコードの出力は、次の通り:
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
<?php
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
上のコードの出力は、次の通り:
test.txt