使用
原文链接:https://www.f2er.com/php/131996.htmlpathinfo()
功能:
$path_parts = pathinfo('/www/htdocs/index.html'); echo $path_parts['dirname'],"\n"; echo $path_parts['basename'],"\n"; echo $path_parts['extension'],"\n"; echo $path_parts['filename'],"\n";
或简单地:
echo pathinfo($file,PATHINFO_EXTENSION);
你当然可以找到最后的“”.在文件名,并得到一切(相对容易),但为什么重新发明轮?