summaryrefslogtreecommitdiff
path: root/function.php
blob: 87ec766b24ee15436d8661af8c154637acb7cc1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

function getHeader($url){
	$agent = "Retrieve HTTP headers online. v0.1";
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($ch, CURLOPT_USERAGENT, $agent);

	$response = curl_exec($ch);
	$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
	$header = substr($response, 0, $header_size);
	return $header;
}