Check If Curl Response Is 200 Php

[Solved] Check If Curl Response Is 200 Php | Php - Code Explorer | yomemimo.com
Question : check if curl response is 200 php

Answered by : shiny-stork

$url = 'http://www.example.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo 'HTTP code: ' . $httpcode;

Source : https://stackoverflow.com/questions/11797680/getting-http-code-in-php-using-curl | Last Update : Mon, 09 Mar 20

Answers related to check if curl response is 200 php

Code Explorer Popular Question For Php