Read title of a website with PHP
Snippet for reading title of a website.
function getPageTitle($sURL)
{
if( ($sHTML = file_get_contents($sURL)) &&
preg_match("/<title>(.+)<\/title>/i", $sHTML, $aTitle))
{
return trim($aTitle[1]);
}
return false;
}
echo utf8_decode(getPageTitle("http://sklueh.de"));
/*
* Ausgabe:
* Sebastian Klüh | Softwareentwicklung und was mich sonst so beschäftigt.
*/
Url: http://sklueh.de/2012/10/titel-einer-webseite-mit-php-auslesen/
Language: PHP | User: sklueh | Created: Sep 24, 2013