复制代码 代码如下:
$url = “http://sinaurl.cn/hbdsU5”;
echo unshorten($url);
function unshorten($url) {
$url = trim($url);
$headers = get_headers($url);
echo unshorten($url);
function unshorten($url) {
$url = trim($url);
$headers = get_headers($url);
http://www.gaodaima.com/48885.htmlphp短域名转换为实际域名函数_php
$location = $url;
$short = false;
foreach($headers as $head) {
if($head==”HTTP/1.1 302 Found”) $short = true;
if($short && startwith($head,”Location: “)) {
$location = substr($head,10);
}
}
return $location;
}
function startwith($Haystack, $Needle){
return strpos($Haystack, $Needle) === 0;
}
欢迎大家阅读《php短域名转换为实际域名函数_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码