How to get page title in php?
<p>I have this function to get title of a website:</p>

<pre><code>function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)&gt;0){
    preg_match("/\&lt;title\&gt;(.*)\&lt;\/title\&gt;/",$str,$title);
    return $title[1];
}
}
</code></pre>

<p>However, this function make my page took too much time to response. Someone tell me to get title by request header of the website only, which won't read the whole file, but I don't know how. Can anyone please tell me which code and function i should use to do this? Thank you very much.</p>
