close
如何取得PHP cURL中的header內容
有兩種方式:
使用CURLOPT_HEADER
或
使用CURLOPT_HEADERFUNCTION
詳細方法如下:
--
There are two ways to get response headres from PHP cURL.
1. Using CURLOPT_HEADER option
With the curl_setopt()
method, when CURLOPT_HEADER
is set to true, curl_exec
will output response header. At this time, if CURLOPT_NOBODY
is set to false, curl_setopt()
will return the response header and content body, otherwise only the response header will be returned.
We can use curl_getinfo($ch, CURLINFO_HEADER_SIZE)
method to return total size of all headers received.
Output
2. Using CURLOPT_HEADERFUNCTION option
With the CURLOPT_HEADERFUNCTION
option, we can set a callback function.
Output
--
轉自 https://blog.cpming.top/p/get-response-header-from-php-curl
全站熱搜