코드 복사 코드는 다음과 같습니다.
$url = "http://sinaurl.cn/hbdsU5"
echo unshorten( $url);
function unshorten($url) {
$url = Trim($url)
$headers = get_headers($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
}