php获取文件扩展名

方法一、使用pathinfo函数

$file = "/path/to/file.xlsx";
$ext = pathinfo($file, PATHINFO_EXTENSION)
echo $ext;

以上代码输出:xlsx

方法二、使用explode函数

$file = "/path/to/file.xls";
$temArr = explode(".", $file);
$ext = end($temArr);
echo $ext;

以上代码输出:xls

原文地址:https://www.cnblogs.com/liyuchuan/p/11606480.html