zl程序教程

您现在的位置是:首页 >  后端

当前栏目

php短域名转换为实际域名函数

PHP转换域名 函数 实际
2023-06-13 09:14:26 时间
复制代码代码如下:

$url="http://sinaurl.cn/hbdsU5";
echounshorten($url);
functionunshorten($url){
$url=trim($url);
$headers=get_headers($url);
$location=$url;
$short=false;
foreach($headersas$head){
if($head=="HTTP/1.1302Found")$short=true;
if($short&&startwith($head,"Location:")){
$location=substr($head,10);
}
}
return$location;
}
functionstartwith($Haystack,$Needle){
returnstrpos($Haystack,$Needle)===0;
}