function get_title url if filter_var url FILTER_VALIDATE_URL data file

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?
function get_title ($url) {
if (filter_var($url, FILTER_VALIDATE_URL)) {
$data = file_get_contents('http://gmodules.com/ig/proxy?url='.$url);
preg_match('/\<title\>(.*)\<\/title\>/', $data, $title);
print (strlen($title[1]) != 0) ? $title[1] : 'ERROR: TITLE_EMPTY';
}
else {
print 'ERROR: URL_INCORRECT';
}
}
header('Content-type: text/html; charset=utf-8');
get_title('https://www.cloudflare.com/');
?>