papaface Posted December 31, 2007 Share Posted December 31, 2007 Hello, How can I check if a remote link returns a 404 error? I understand it has something to do with headers but I'm not entirely sure. Any help would be appreciated! Link to comment https://forums.phpfreaks.com/topic/83787-solved-check-for-a-404-error/ Share on other sites More sharing options...
papaface Posted December 31, 2007 Author Share Posted December 31, 2007 I have this: <?php $url = "http://video.stage6.com/1957687/.divx"; $valid = fsockopen("$url", 80, $errno, $errstr, 30); if ($valid) echo "active"; else echo "dead"; ?> I'm trying to test whether or not a link is still active or not. The code above doesn't work because that link forces a download. A unactive link shows a 404 error on the page. Link to comment https://forums.phpfreaks.com/topic/83787-solved-check-for-a-404-error/#findComment-426339 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.