网页Http返回状态值查询(404,200,301,302,500)这种怎么实现呢

WBOY
Release: 2016-06-13 10:07:43
Original
917 people have browsed it

网页Http返回状态值查询(404,200,301,302,500)这种如何实现呢?
例如像这个网站的。
可以查询网站的返回状态

http://www.mjjer.com/gethttpheader.php

------解决方案--------------------
curl为例:

PHP code
function curl_file_get_contents($durl){    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, $durl);    curl_setopt($ch, CURLOPT_TIMEOUT, 30);    curl_setopt($ch, CURLOPT_HEADER, true);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    $r = curl_exec($ch);    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);     return $http_code;}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!