php如何获得文件扩大名
要获得文件扩大名,可使用PHP的pathinfo()函数还是explode()函数。
使用pathinfo()函数:
$file = 'example.txt';
$ext = pathinfo($file, PATHINFO_EXTENSION);
echo $ext; // 输出:txt
使用explode()函数:
$file = 'example.txt';
$ext = explode('.', $file);
$ext = end($ext);
echo $ext; // 输出:txt
以上两种方法都可以获得文件的扩大名。
TOP