
Check the HTTP Status Code of the website header using PHP. Check that url is giving valid response code of 2xx. You can modify this for different purposes. For detecting 404 not found only or separate error reporting for error 500.
Source code viewer
function is_working_url($url) { if ($httpCode >= 200 && $httpCode < 300) { return true; } else { return false; } }Programming Language: PHP