Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to request head of url ??

Status
Not open for further replies.

hos2

Programmer
May 6, 2002
418
NL
I want to check all my links on availability in my database from time to time. Is it possible to request the header information of any given url ?? and store that in a variable ?
 
function urlExists($url)
{
$url = ereg_replace(""", $url);
list($domain, $file) = explode("/", $url, 2);
$fid=fsockopen($domain,80);
fputs($fid,"HEAD /$file HTTP/1.0\r\nHost: $domain\r\n\r\n");
$gets = fgets($fid, 1024);
fclose($fid);
if (ereg("HTTP/1.1 200 OK", $gets)) return TRUE;
else return FALSE;
}

i just found out this code in php.net.
i hope it will help you out Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
hmm on php.net it mentioned also that it doesn't work on remote files. and I have only remote urls in my database. further on I want to read the header information of the requested url and not only true or false

I will check it out anyway for future use. thanks
 
look, you're not using the file_exists function in the function i gave you.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Ah I see, it seems to work :) sorry I also search on php.net first but that didn't work. I didn't notice the chancge in function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top