1Answer
<?php
//if
$url="http://www.answerspoint.com/questions/403/how-to-find-page-title-and-meta-content-of-html-using-php";
//for Meta tag (keyword, description)
$tags = get_meta_tags($url);
$meta_keywords=$tags['keywords'];
$meta_description=$tags['description'];
//for Page Title
$page_title=pageTitle($url);
function pageTitle($page_url)
{
$read_page=file_get_contents($page_url);
preg_match("/<title.*?>[\n\r\s]*(.*)[\n\r\s]*<\/title>/", $read_page, $page_title);
if (isset($page_title[1]))
{
if ($page_title[1] == '')
{
return $page_url;
}
$page_title = $page_title[1];
return trim($page_title);
}
else
{
return $page_url;
}
}
?>
- answered 8 years ago
- Sunny Solu
Your Answer