PHP 8.5.0 Alpha 1 available for testing

Voting

: seven minus two?
(Example: nine)

The Note You're Voting On

info at marc-gutt dot de
17 years ago
Should be the same than the original get_headers():

<?php
if (!function_exists('get_headers')) {
function
get_headers($url, $format=0) {
$headers = array();
$url = parse_url($url);
$host = isset($url['host']) ? $url['host'] : '';
$port = isset($url['port']) ? $url['port'] : 80;
$path = (isset($url['path']) ? $url['path'] : '/') . (isset($url['query']) ? '?' . $url['query'] : '');
$fp = fsockopen($host, $port, $errno, $errstr, 3);
if (
$fp)
{
$hdr = "GET $path HTTP/1.1\r\n";
$hdr .= "Host: $host \r\n";
$hdr .= "Connection: Close\r\n\r\n";
fwrite($fp, $hdr);
while (!
feof($fp) && $line = trim(fgets($fp, 1024)))
{
if (
$line == "\r\n") break;
list(
$key, $val) = explode(': ', $line, 2);
if (
$format)
if (
$val) $headers[$key] = $val;
else
$headers[] = $key;
else
$headers[] = $line;
}
fclose($fp);
return
$headers;
}
return
false;
}
}
?>

<< Back to user notes page

To Top