note 47290 deleted from function.get-headers by nlopess

From: Date: Thu, 20 Jan 2005 13:21:18 +0000
Subject: note 47290 deleted from function.get-headers by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83680@lists.php.net to get a copy of this message
Note Submitter: jamaz ---- get_headers() for PHP4. This is modified version of cpurruc's function get_headers_php4(). Changes: + removes empty headers + you don't need to care about PHP version and function name, when calling get_headers() <?php if(!function_exists('get_headers')) { /** * @return array * @param string $url * @desc Fetches all the headers * @author cpurruc fh-landshut de */ function get_headers($url) { $url_info=parse_url($url); $fp=fsockopen($url_info['host'], 80, $errno, $errstr, 30); if($fp) { $head = "HEAD ".$url_info['path']."?".$url_info['query']." HTTP/1.0\r\n" . "Host: ".$url_info['host']."\r\n\r\n"; fputs( $fp, $head ); while(!feof($fp)) { if($header=trim(fgets($fp, 1024))) { $headers[]=$header; } } return $headers; } } } ?>

« previous php.notes (#83680) next »