PHP get http header response code without cURL

后端 未结 2 1762
误落风尘
误落风尘 2021-02-09 16:20

I have written a class that detects if cURL is available, if it is performs GET, POST, DELETE using cURL. In the cURL version I use curl_getinfo($curl, CURLINFO_HTTP_CO

2条回答
  •  太阳男子
    2021-02-09 17:01

    Whenever you do some HTTP interaction, the special variable $http_response_header on the same scope will contain all headers (incl. the status line header) that are resulted from the last HTTP interaction.

    See here for an example how to parse it and obtain the status code.

提交回复
热议问题