How can I check if a URL exists via PHP?

前端 未结 22 1643
天涯浪人
天涯浪人 2020-11-22 04:13

How do I check if a URL exists (not 404) in PHP?

22条回答
  •  一整个雨季
    2020-11-22 05:01

    to check if url is online or offline ---

    function get_http_response_code($theURL) {
        $headers = @get_headers($theURL);
        return substr($headers[0], 9, 3);
    }
    

提交回复
热议问题