PHP获取文件后缀的5种方法


//第1种方法: function get_extension($file) { substr(strrchr($file, '.'), 1); } //第2种方法: function get_extension($file) { return substr($file, strrpos($file, '.')+1); } //第3种方法: function get_extension($file) { return end(explode('.', $file)); } //第4种方法: function get_extension($file) { $info = pathinfo($file); return $info['extension']; } //第5种方法: function get_extension($file) { return pathinfo($file, PATHINFO_EXTENSION); }
转摘https://www.jianshu.com/p/8da4e7e5bd15


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM