PHP – HOW TO: check if a URL exists or not ?
August 26th, 2008
No comments
1'st php function (the simplest way):
function test_url_file($url) {
$res = (($ftest = @fopen($url, 'r')) === false) ? false : @fclose($ftest);
return ($res == TRUE) ? 1:0 ;
}
2'nd php function, using fsockopen (not so simple) !
function test_url_file2($url) {
$addr=parse_url($url);
$host=$addr['host'];
$path = $addr['path'];
$headtxt = '';
if($sock=fsockopen($host,80, $errno, ...
Categories: Bookmarks, PhP, Tech check URL exists, php check url, php fopen, php fsockopen, PHP Function








