Created
August 26, 2018 14:02
-
-
Save vladdu/fb8e8e178913840de484c104fe740c4b to your computer and use it in GitHub Desktop.
check if a link is broken with php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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