1

i try to return the header response from specific url using CURL function

this is my code

$strURL = "http://162.253.132.165";



$resCurl = curl_init();

//set URL and other appropriate options
curl_setopt($resCurl, CURLOPT_URL, $strURL);
curl_setopt($resCurl, CURLOPT_HEADER, true);
curl_setopt($resCurl, CURLOPT_NOBODY, true);
curl_setopt($resCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($resCurl, CURLOPT_FOLLOWLOCATION, true);

//get the headers
$strHeaders = curl_exec($resCurl);

//close cURL
curl_close($resCurl);

echo $strHeaders;

enter image description here

the problem is that i need only the success response output for 200 OK

and i use this for SSL and https protocols how i can do that ?

Ahmed Safadi
  • 433
  • 1
  • 6
  • 19
  • Or more literally: [How to get the headers from the last redirect with PHP's curl functions?](http://stackoverflow.com/q/3326774) – mario May 18 '16 at 22:08
  • echo curl_getinfo($resCurl, CURLINFO_HTTP_CODE); – Kevin_Kinsey May 18 '16 at 22:09
  • mario , when u use the https with get_headers not working :/ ,, that's why i use curl , they also it's more speed – Ahmed Safadi May 18 '16 at 22:15
  • _"i need only the success response output for 200 OK"_ - then you should probably make that a HEAD request in the first place ... (especially since you're after "speed" as well.) – CBroe May 18 '16 at 22:27

0 Answers0