复制代码代码如下:
$url = "http://sinaurl.cn/hbdsU5";
echo unshorten($url);
関数 unshorten($url) {
$url = トリム($url);
$headers = get_headers($url);
$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);
}
}
$location を返します。
}
関数 startwith($Haystack, $Needle){
return strpos($Haystack, $Needle) === 0;
}
http://www.bkjia.com/PHPjc/322812.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322812.html技術記事复制代码代码如下: $url = "http://sinaurl.cn/hbdsU5";エコー非短縮($url);関数 unshorten($url) { $url = トリム($url); $headers = get_headers($url); $location = $url; $s...