Posted By

tylerhall on 09/25/06


get http header

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Retrieve HTTP Header

 / Published in: PHP

This returns the headers from an HTTP request. I'm sure there's a better way to do this without resorting to output buffering, but it works.

  1. function getheader($url)
  2. {
  3. $ch = curl_init($url);
  4. curl_setopt($ch, CURLOPT_HEADER, 1);
  5. curl_setopt($ch, CURLOPT_NOBODY, 1);
  6. $ok = curl_exec($ch);
  7. curl_close($ch);
  8. $head = ob_get_contents();
  9. return $head;
  10. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: tylerhall on September 30, 2006

PHP5 has this function built-in, however it's nice to have this laying around if you're forced to use PHP4.

You need to login to post a comment.