get_headers
La funzione get_headers effettua il recupero di tutti gli headers restituiti dal server a seguito di una chiamata HTTP. Vediamo un esempio:
print_r(get_headers("http://www.google.it"));
restituisce una array come questa:
Array
(
[0] => HTTP/1.0 200 OK
[1] => Cache-Control: private, max-age=0
[2] => Date: Thu, 18 Sep 2008 23:33:16 GMT
[3] => Expires: -1
[4] => Content-Type: text/html; charset=ISO-8859-1
[5] => Set-Cookie: PREF=ID=5ed27189f661d029:TM=1221780796:LM=1221780796:S=I0idTwSeHmzzm72R; expires=Sat, 18-Sep-2010 23:33:16 GMT; path=/; domain=.google.it
[6] => Server: gws
[7] => Connection: Close
)
La funzione in oggetto ammette anche un secondo argomento (facoltativo) format. Vediamo un esempio con il parametro format settato su 1:
print_r(get_headers("http://www.google.it", 1));
L'array restituita è la seguente:
Array
(
[0] => HTTP/1.0 200 OK
[Cache-Control] => private, max-age=0
[Date] => Thu, 18 Sep 2008 23:34:46 GMT
[Expires] => -1
[Content-Type] => text/html; charset=ISO-8859-1
[Set-Cookie] => PREF=ID=00686f5402c73192:TM=1221780885:LM=1221780885:S=LaAYrpUJHJlb53xi; expires=Sat, 18-Sep-2010 23:34:45 GMT; path=/; domain=.google.it
[Server] => gws
[Connection] => Close
)
');







