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;
?>
顶(1)
踩(0)
- 最新评论
