首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

PHP检测远端资料是否存在

2012-10-31 
PHP检测远端文件是否存在?php/** * Fetches all the real headers sent by the server in response to a

PHP检测远端文件是否存在

<?php/** * Fetches all the real headers sent by the server in response to a HTTP request without redirects * 获取不包含重定向的报头 */ function get_real_headers($url,$format=0,$follow_redirect=0) {  if (!$follow_redirect) {    //set new default options    $opts = array('http' =>        array('max_redirects'=>1,'ignore_errors'=>1)    );    stream_context_get_default($opts);  }  //get headers    $headers=get_headers($url,$format);    //restore default options  if (isset($opts)) {    $opts = array('http' =>        array('max_redirects'=>20,'ignore_errors'=>0)    );    stream_context_get_default($opts);  }  //return    return $headers;}?> 
?

热点排行