问题:
This is a question you can read everywhere on the web with various answers: 这是一个您能够在网上处处阅读的各类问题,并有各类答案: web
$ext = end(explode('.', $filename)); $ext = substr(strrchr($filename, '.'), 1); $ext = substr($filename, strrpos($filename, '.') + 1); $ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename); $exts = split("[/\\.]", $filename); $n = count($exts)-1; $ext = $exts[$n];
etc. 等等 spa
However, there is always "the best way" and it should be on Stack Overflow. 可是,总有“最佳方法”,它应该在堆栈溢出中。 .net
解决方案:
参考一: https://stackoom.com/question/jEK/如何获取-提取-PHP文件扩展名参考二: https://oldbug.net/q/jEK/How-do-I-get-extract-a-file-extension-in-PHP