note 82363 added to function.headers-list
| From: | slick | Date: | Tue, 08 Apr 2008 04:52:54 +0000 |
| Subject: | note 82363 added to function.headers-list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138016@lists.php.net to get a copy of this message | ||
To: leo at leoberkhout dot nl,
in PHP 5.0 get_headers() already exists so when i went through your code and organized it i had a
small problem with that. Other than that when i changed the function name it worked fine. Of course
i did tweak a few minor things to make it so. But this is what i've got.
<?php
function gimme_headers($host,$url) {
$headers = array();
$fp = fsockopen ($host,80,$errno,$errstr,45);
if($fp) {
fputs($fp,"GET $url HTTP/1.0\r\n\r\n");
while(!feof($fp)) {
$char = fgetc($fp);
if($char === "\n") {
if(ord($header) === 13) {
return($headers);
}
else {
array_push($headers,trim($header));
}
unset($header);
}
else {
$header = $header . $char;
}
}
fclose ($fp);
}
}
if(isset($_GET['uri'])) {
$uri = $_GET['uri'];
}
else {
$uri = 'php.net';
}
$array = gimme_headers($uri, "/");
print 'Cookie list for ' . $uri;
print '<ul>';
foreach ($array as $key => $value) {
print '<li>' . $_SERVER[$key] . ' = ' . $value .
'</li>';
}
print '</ul>';
?>
----
Server IP: 209.41.74.194
Probable Submitter: 66.138.74.147
----
Manual Page -- http://www.php.net/manual/en/function.headers-list.php
Edit -- https://master.php.net/note/edit/82363
Del: integrated -- https://master.php.net/note/delete/82363/integrated
Del: useless -- https://master.php.net/note/delete/82363/useless
Del: bad code -- https://master.php.net/note/delete/82363/bad+code
Del: spam -- https://master.php.net/note/delete/82363/spam
Del: non-english -- https://master.php.net/note/delete/82363/non-english
Del: in docs -- https://master.php.net/note/delete/82363/in+docs
Del: other reasons-- https://master.php.net/note/delete/82363
Reject -- https://master.php.net/note/reject/82363
Search -- https://master.php.net/manage/user-notes.php