Arkadaşlar CURL ile header'den gelen verileri alabildim. PHP4 kullanan arkadaşlar get_headers() fonksiyonu yerine aşağıdaki CURL fonksiyonunu kullanabilirler.
<?php
function get_http_header( $url ){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_HEADER, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_NOBODY, 1 );
$ret = curl_exec( $ch );
curl_close( $ch );
return $ret;
}
// kullanımı
echo get_http_header("http://www.google.com.tr");
?>fonksiyon çalıştığında aşağıdakine benzer çıktı verir:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=ISO-8859-9
Set-Cookie: PREF=ID=360a92f8cd9b860c:TM=1184690329:LM=1184690329:S=4s8HFcQGxls1yGjK; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com.tr
Server: GWS/2.1
Content-Length: 0
Date: Tue, 17 Jul 2007 16:38:49 GMT