- 获取文件夹路径:
dirname($path)
- 获取文件名:
basename($path)
- 获取文件后缀:
pathinfo($path,PATHINFO_EXTENSION)
- 示例:
a. 代码:
<?php
$path = "a/b/lee.jpg";
$dir = dirname($path);
$file = basename($path);
$ext = pathinfo($path,PATHINFO_EXTENSION);
echo $dir;
echo "\n";
echo $file;
echo "\n";
echo $ext;
b. 输出:
a/b
lee.jpg
jpg
|