PHP 获取URL的文件后缀名

答案

PHP获取URL的文件后缀名代码:

  1. function getExt($url) {
  2. $data = parse_url($url);
  3. $path = $data['path'];
  4. $info = pathinfo($path);
  5. return $info['extension'];
  6. }
  7. echo getExt('http://www.jintix.com/q/1670.html?id=1670');
  8. // 结果: html