快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

PHP获取网站HTTP header返回的报头HTTP状态代码

代码如下:获得谷歌的状态代码,一般是200,404,301这些状态代码

<?php   
/*  
获得HTTP服务器状态,可以用于检查404,500等服务器错误  
*/  
error_reporting(0);
$request =  'http://www.google.com/';
//请求文件  
$html = file_get_contents($request);
//返回HTTP状态码   
list($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);
echo "HTTP status code:",$status_code;   
?>

演示页面:http://www.bnxb.com/tools/statu.html

顶(1)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论