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.uoften.com/abc/de/fg.php?id=1');
?>
最后
以上就是懵懂大白最近收集整理的关于php获取url字符串截取路径的文件名和扩展名的函数的全部内容,更多相关php获取url字符串截取路径内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复