Skip to content

Instantly share code, notes, and snippets.

@acidtib
Forked from vyspiansky/remote-file-exists.php
Created July 27, 2016 19:57
Show Gist options
  • Save acidtib/eeead3229e872a901855a5eb1dc37e8e to your computer and use it in GitHub Desktop.
Save acidtib/eeead3229e872a901855a5eb1dc37e8e to your computer and use it in GitHub Desktop.
PHP: file_exists for remote URL
<?php
// Source: http://goo.gl/aZ1h8v
$file_headers = @get_headers($url);
if ($file_headers[0] == 'HTTP/1.0 404 Not Found'){
$file_exists = false;
} else {
$file_exists = true;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment