时间:2021-07-01 10:21:17 帮助过:2人阅读
本文实例讲述了php从给定url获取文件扩展名的方法。分享给大家供大家参考。具体实现方法如下:
- <?php
- /**
- * 给定url,获取文件后缀
- * @param string $url
- * @return string
- */
- function getUrlPostfix ($url)
- {
- $url_arr = explode('.', $url);
- $postfix = $url_arr[count($url_arr) - 1];
- $substr = substr($postfix, 0, 3);
- return $substr;
- }
- $url = "http://www.gxlcms.com/index.html?id=1";
- $str = getUrlPostfix($url);
- echo $str . "\n";
以上就是php从给定url获取文件扩展名的方法详解的详细内容,更多请关注Gxl网其它相关文章!