首页 > 编程 > PHP > 正文

php获取url字符串截取路径的文件名和扩展名的函数

2019-11-22 01:16:10
字体:
来源:转载
供稿:网友
php获取文件名
复制代码 代码如下:

function retrieve($url)
{
preg_match('///([^//]+/.[a-z]+)[^//]*$/',$url,$match);
return $match[1];
}

php获取文件扩展名
复制代码 代码如下:

<?php
function getExt($url)
{
$path=parse_url($url);
$str=explode('.',$path['path']);
return $str[1];
}
echo getExt('http://tools.VeVB.COm/abc/de/fg.php?id=1');
?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表