taqgza
Last Updated: February 25, 2016
·
799
· milos_matic
Profil milosmatic

Check for valid (not dead) links using PHP

function is_available($url, $timeout = 30) {
    $ch = curl_init(); // get cURL handle
    $opts = array(
        CURLOPT_RETURNTRANSFER => true, 
        CURLOPT_URL => $url,
        CURLOPT_NOBODY => true
        CURLOPT_TIMEOUT => $timeout
    );
    curl_setopt_array($ch, $opts); 
    curl_exec($ch); 
    $retval = curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200;
    curl_close($ch); 
    return $retval;
}
Say Thanks
Respond

1 Response
Add your response

2781
Pro pic

@milos_matic solid!

over 1 year ago ·