Beni Takip Edebilirsin
Php get_headers Nedir ve Nasıl Kullanılır
Php ile get_headers(); Bir HTTP isteğine sunucunun verdiği yanıtta gönderilen tüm başlıkları döndürür.
Örnegin bir dosyanın boyutunu v.s öğrenmek için get_header ise http istegine gönderilen veriden cekebilirsiniz.
Kullanımı :
<?php
$f = get_headers("http://facebook.com");
print_r($f);
?>
Çıktı :
Array | |
( | |
[0] => HTTP/1.1 301 Moved Permanently | |
[1] => Location: https://facebook.com/ | |
[2] => Vary: Accept-Encoding | |
[3] => Content-Type: text/html | |
[4] => X-FB-Debug: Ue/09gyc5EVG7jHgEmjzdOeefv994ubSyAK/G+opoM8+Lddrs2N6dwTMV4p7SIbu3aPxsKAW0nVYwJnWucXmvg== | |
[5] => Date: Wed, 10 Aug 2016 18:50:08 GMT | |
[6] => Connection: close | |
[7] => Content-Length: 0 | |
[8] => HTTP/1.0 301 Moved Permanently | |
[9] => Location: https://www.facebook.com/ | |
[10] => Strict-Transport-Security: max-age=15552000; preload | |
[11] => Vary: Accept-Encoding | |
[12] => Cache-Control: public, max-age=2592000 | |
[13] => Content-Type: text/plain | |
[14] => Server: proxygen | |
[15] => Date: Wed, 10 Aug 2016 18:50:10 GMT | |
[16] => Connection: close | |
[17] => Content-Length: 0 | |
[18] => HTTP/1.1 302 Found | |
[19] => Location: https://www.facebook.com/unsupportedbrowser | |
[20] => Vary: Accept-Encoding | |
[21] => Content-Type: text/html | |
[22] => X-FB-Debug: 2EUFTYiri0M8FNQ0tmpBxrYcICCL9pyyeoNw4L6noimm8iDJ8YdHKQHFxFuw2ZrfyBPkVyKJwURTz9ht0r8pLA== | |
[23] => Date: Wed, 10 Aug 2016 18:50:11 GMT | |
[24] => Connection: close | |
[25] => Content-Length: 0 | |
[26] => HTTP/1.1 200 OK | |
[27] => P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p" | |
[28] => Strict-Transport-Security: max-age=15552000; preload | |
[29] => Cache-Control: private, no-cache, no-store, must-revalidate | |
[30] => Expires: Sat, 01 Jan 2000 00:00:00 GMT | |
[31] => Pragma: no-cache | |
[32] => public-key-pins-report-only: max-age=500; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="; pin-sha256="q4PO2G2cbkZhZ82+JgmRUyGMoAeozA+BSXVXQWB8XWQ="; report-uri="http://reports.fb.com/hpkp/" | |
[33] => X-Content-Type-Options: nosniff | |
[34] => X-XSS-Protection: 0 | |
[35] => X-Frame-Options: DENY | |
[36] => Set-Cookie: fr=0RU3PVxKy4SH2oXtD..BXq3dj.om.AAA.0.0.BXq3dj.AWXvffjl; expires=Tue, 08-Nov-2016 18:50:11 GMT; Max-Age=7776000; path=/; domain=.facebook.com; httponly | |
[37] => Vary: Accept-Encoding | |
[38] => Content-Type: text/html | |
[39] => X-FB-Debug: +CE6+TnWnVuNmbez0rGuEORRytOjRpGHqoX4QjDDalG4U0e+eBMsUjZof9dgf6yc+hXBesdbr954dgEObnAXWQ== | |
[40] => Date: Wed, 10 Aug 2016 18:50:11 GMT | |
[41] => Connection: close | |
) | |
Eğer get_headers(); 2. parametresine 1 yazarsak cıktıya bakalım.
Kullanımı :
<?php
$f = get_headers("http://facebook.com",1);
print_r($f);
?>
Çıktı :
Array | |
( | |
[0] => HTTP/1.1 301 Moved Permanently | |
[Location] => Array | |
( | |
[0] => https://facebook.com/ | |
[1] => https://www.facebook.com/ | |
[2] => https://www.facebook.com/unsupportedbrowser | |
) | |
[Vary] => Array | |
( | |
[0] => Accept-Encoding | |
[1] => Accept-Encoding | |
[2] => Accept-Encoding | |
[3] => Accept-Encoding | |
) | |
[Content-Type] => Array | |
( | |
[0] => text/html | |
[1] => text/plain | |
[2] => text/html | |
[3] => text/html | |
) | |
[X-FB-Debug] => Array | |
( | |
[0] => 6bh/Fp1BWxqANmiDZv0HeKbc28jMulKIr6FOwbx+1hB0eYVXfXKH8Q3WpsQBoxMTVZEdYmBcYzfWpsU414l+ag== | |
[1] => i6vYdikKV63EMhBjei6+sNL5OhH1Mojbbfku0dlH9ZACB2TJ9Rqb+VF/GS7sA5+WTX3CLGDBuEAS8hJu/MORsQ== | |
[2] => RLONrXnLntsd4PCInS3FNgA8z1vsrI3fsH65U7puBuruQICo8Vg1mMVouop4jLuNPnYUmMVJal3sPC8ima4yIA== | |
) | |
[Date] => Array | |
( | |
[0] => Wed, 10 Aug 2016 18:51:20 GMT | |
[1] => Wed, 10 Aug 2016 18:51:21 GMT | |
[2] => Wed, 10 Aug 2016 18:51:24 GMT | |
[3] => Wed, 10 Aug 2016 18:51:25 GMT | |
) | |
[Connection] => Array | |
( | |
[0] => close | |
[1] => close | |
[2] => close | |
[3] => close | |
) | |
[Content-Length] => Array | |
( | |
[0] => 0 | |
[1] => 0 | |
[2] => 0 | |
) | |
[1] => HTTP/1.0 301 Moved Permanently | |
[Strict-Transport-Security] => Array | |
( | |
[0] => max-age=15552000; preload | |
[1] => max-age=15552000; preload | |
) | |
[Cache-Control] => Array | |
( | |
[0] => public, max-age=2592000 | |
[1] => private, no-cache, no-store, must-revalidate | |
) | |
[Server] => proxygen | |
[2] => HTTP/1.1 302 Found | |
[3] => HTTP/1.1 200 OK | |
[P3P] => CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p" | |
[Expires] => Sat, 01 Jan 2000 00:00:00 GMT | |
[Pragma] => no-cache | |
[public-key-pins-report-only] => max-age=500; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="; pin-sha256="q4PO2G2cbkZhZ82+JgmRUyGMoAeozA+BSXVXQWB8XWQ="; report-uri="http://reports.fb.com/hpkp/" | |
[X-Content-Type-Options] => nosniff | |
[X-XSS-Protection] => 0 | |
[X-Frame-Options] => DENY | |
[Set-Cookie] => fr=00mFiyOlcbXaCQMOO..BXq3et.tY.AAA.0.0.BXq3et.AWXtcsqn; expires=Tue, 08-Nov-2016 18:51:25 GMT; Max-Age=7776000; path=/; domain=.facebook.com; httponly | |
) | |
Paylaş:
Yorumlar: