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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get header from url file ?

Status
Not open for further replies.

KeziaKristina

Programmer
Nov 1, 2002
13
ID

How can i get/read a header of url ?
I have try this function,


function get_headers($host, $path = "/")
{
$fp = fsockopen ("$host", 80, &$errnr, &$errstr) or die("$errno: $errstr");
fputs($fp,"GET $path HTTP/1.0\n\n");
while (!$end)
{
$line = fgets($fp, 2048);
if (trim($line) == "")
$end = true;
else
echo $line;
}
fclose($fp);
}

sometimes it doesn't work sometimes it works, but it display a warning message

Warning: fsockopen() [function.fsockopen]: php_hostconnect: connect failed in ....

Warning: fsockopen() [function.fsockopen]: unable to connect to prdownloads.sourceforge.net:80 in ...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top