public function file_extension(){
$filename = input('filename');
$pathinfo=pathinfo($filename);
return strtolower($pathinfo['extension']);
}
strtolower() 函数把字符串转换为小写。
说明
pathinfo() 返回一个关联数组包含有 path 的信息。
包括以下的数组元素:
[dirname]
[basename]
[extension]
print_r(pathinfo("/testweb/test.txt"));
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
php获取文件扩展名
最新推荐文章于 2023-06-11 10:07:53 发布