如何获取(提取)PHP文件扩展名? - How do I get (extract) a file extension in PHP?

07/06 10:50
阅读数 38

问题:

This is a question you can read everywhere on the web with various answers: 这是一个您可以在网上到处阅读的各种问题,并有各种答案:

$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. 等等

However, there is always "the best way" and it should be on Stack Overflow. 但是,总有“最佳方法”,它应该在堆栈溢出中。


解决方案:

参考一: https://stackoom.com/question/jEK/如何获取-提取-PHP文件扩展名
参考二: https://oldbug.net/q/jEK/How-do-I-get-extract-a-file-extension-in-PHP
展开阅读全文
php
打赏
1
0 收藏
分享
加载中
赞一赞
07/06 11:05
回复
举报
更多评论
打赏
1 评论
0 收藏
1
分享
返回顶部
顶部