PHP cURL HTTP CODE return 0

前端 未结 9 1999
青春惊慌失措
青春惊慌失措 2020-11-29 23:03

I dont understand when I echo $httpCode I always get 0, I was expecting 404 when I change $html_brand into a broken url. Is there anything that I miss or do not know of? Tha

9条回答
  •  野性不改
    2020-11-29 23:22

    Like said here and below, a failed request (i.e. the server is not found) returns false, no HTTP status code, since a reply has never been received.

    Call curl_error().

提交回复
热议问题