如何在PHP中打印从CURL调用获得的响应头? <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "myurl", CURLOPT_

如何在PHP中打印从CURL调用获得的响应头? <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "myurl", CURLOPT_,curl,php-curl,Curl,Php Curl,如何在PHP中打印从CURL调用获得的响应头? <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "myurl", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT

如何在PHP中打印从CURL调用获得的响应头?

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "myurl",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\"cost\":93.86,\"price\":77.54,\"description\":\"Hello wrold 2\",\"long_description\":\"This test\",\"custom\":{\"size\":\"M\"}}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer mytoken",
    "Content-Type: application/json",
    "Content-Type: text/plain",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;