例如给定
http://www.*.com/index.html?id=1
返回.html
/**
* PHP从给定的url获取文件扩展名
*
* @param
* @arrange 512-笔记网: www.512Pic.com
* 给定url,获取文件后缀
* @param string $url
* @return string
*/
function getUrlPostfix ($url)
{
$url_arr = explode('.',$url);
$postfix = $url_arr[count($url_arr) - 1];
$substr = substr($postfix,3);
return $substr;
}
$url = "http://www.*.com/index.html?id=1";
$str = getUrlPostfix($url);
echo $str . "\n";
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528354.html