Algemeen en interessant nieuws over en door NosTech

NIEUWS

PHP: url_exists() extends the file_exists() function                                                 If you want...
16-06-2008 15:58

PHP: url_exists() extends the file_exists() function                                                

If you want to check on remote files wether they exist or not, it’s not possible with file_exists(). So below you can find a function which allows you to check on these files. The code can also be found on php.net

function url_exists($url)
{
    $handle = curl_init($url);
    if (false === $handle)
    {
        return false;
    }
    curl_setopt($handle, CURLOPT_HEADER, false);
    curl_setopt($handle, CURLOPT_FAILONERROR, true);
    curl_setopt($handle, CURLOPT_NOBODY, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
    $connectable = curl_exec($handle);
    curl_close($handle);
    return $connectable;
}

< Alle nieuws