Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php curl detect 404

$handle = curl_init($url);
curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);

/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
    /* Handle 404 here. */
}

curl_close($handle);

/* Handle $response here. */
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #curl #detect
ADD COMMENT
Topic
Name
9+2 =