You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

file_exists() is useful function can check the availability of the file. Below example enables you to check file availability not only local but also remote file as well.


function file_exists($url)
{
        if (preg_match("/http/", $url))
        {
                $header_response = @get_headers($url, true);
                if (preg_match("/200 OK/", $header_response[0])) return true;
                else return false;
        }
        else return (file_exists( $url) ? true:false);
}


  • No labels