Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt

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.



Code Block
// custom file_exists check file availability (local/remote)

function filecfile_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);
}

...