Skip to content

Instantly share code, notes, and snippets.

@vladdu
Created August 26, 2018 14:02
Show Gist options
  • Save vladdu/fb8e8e178913840de484c104fe740c4b to your computer and use it in GitHub Desktop.
Save vladdu/fb8e8e178913840de484c104fe740c4b to your computer and use it in GitHub Desktop.
check if a link is broken with php
function check_url($url) {
$headers = @get_headers( $url);
$headers = (is_array($headers)) ? implode( "\n ", $headers) : $headers;
return (bool)preg_match('#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment