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

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

$url = "http://sinaurl.cn/hbdsU5";
echo unshorten($url);
function unshorten($url) {
$url = trim($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);
}
}
return $location;
}
function startwith($Haystack, $Needle){
return strpos($Haystack, $Needle) === 0;
}

相关文章

PHP实现获取ip地址的5种方法,以及插入用户登录日志操作示例

本文实例讲述了PHP实现获取ip地址的5种方法,以及插入用户登录日志操作。分享给大家供大家参考,具体如下: php 获取ip地址的5种方法,插入用户登录日志实例,推荐使用第二种方法...

PHP定时任务延缓执行的实现

复制代码 代码如下: /* |--------------------------- |PHP定时任务 |@黑眼诗人 <www.chenwei.ws> |----------...

谈谈PHP连接Access数据库的注意事项

谈谈PHP连接Access数据库的注意事项

首先需要注意: 安装access 数据库的时候 需要安装与本机系统相互匹配的office版本,win7 64位的系统 ,那么Office也要是64位的 最好装 office2010。。。...

php var_export与var_dump 输出的不同

问题发现在跟踪yratings_get_targets的时候,error_log(var_export(yblog_mspconfiginit("ratings"),true));老是打...

ASP和PHP都是可以删除自身的

z.asp 复制代码 代码如下:<%  s= Server.MapPath("z.asp")  Set fso = Cr...