note 42903 deleted from function.get-headers by nlopess

From: Date: Mon, 06 Sep 2004 17:00:20 +0000
Subject: note 42903 deleted from function.get-headers by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76109@lists.php.net to get a copy of this message
Note Submitter: skinums_frostbot_com ---- I've made a backport of this function. I have tested with php4, it should also work for php3. <?php /** * @return array * @param string $url * @desc Fetches all the headers sent by the server in response to a HTTP request. * @author skinums <skinums_frostbot_com> */ function get_headers_php4($url) { $url_info = parse_url($url); $fp = fsockopen($url_info['host'],80,$errno,$errstr,30); if (!$fp) { exit; } else { $head = "GET ".$url_info['path']."?".$url_info['query']; $head .= " HTTP/1.0\r\nHost: ".$url_info['host']."\r\n\r\n"; fputs($fp,$head); while(!feof($fp)) { $line = fgets($fp,1024); if (strpos($line,"\r\n",0) === 0) { fclose($fp); return $header; } else { $header[] = $line; } } } } ?> -= skin =-

« previous php.notes (#76109) next »