您当前的位置:首页 > 文章教程 > 计算机与互联网 > 网络编程

面试题20从一个标准URL里取出文件的扩展名

面试题20从一个标准URL里取出文件的扩展名

面试题20 从一个标准URL里取出文件的扩展名

例如:http://www.sina.com.cn/abc/de/fg.html?id=1需要取出html。

【分析】


<?php

function getExt($url){

$arr=parse_url($url);

$file=basename($arr["path"]);

$ext=explode(".",$file);

return$ext[1];

}

echo getExt("http://www.sina.com.cn/abc/de/fg.html?id=1")

?>