<?php
function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
return $title[1];
}
}
echo getTitle("http://www.stackoverflow.com/");
?>
When i run this script it returns the error
max_execution_time exceeds 30 second.
I don’t want to increase the max_execution_time but i want to decrease the script run time.
You’re collecting the whole page. Why not just specify the
$maxlenparam and just get more or less the header of the page where the title tag is in? This would give you a little speedup.string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )