Posts Tagged ‘pagetitle’
Get any Website Page Title From URL in PHP
July 9, 2013
Leave a comment
Hey guys,here below describe the how to get the page title form any website page using URL. Here for getting the page title we are using the file_get_contents function.This one also achieve using fopen( ) but in some servers disabled this function now a days due to some security reasons.
Here below shows the PHP code to get the page title form the URL.
<!--?php
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;
}
}
?>
Categories: 2013, ajax, balt., blog, computer, face book, Facebook, Facebook integration, General, google, https://selvabalaji.wordpress.com, internet, News, Open-source, pagination, Paypal, PHP, php function, Plugin, political, selvabalaji, seo, web services, Wordpress, World News
computer, file_get_contents, fopen, MySQL, pagetitle, PHP, php code, php function, preg_match, security reasons, software, Technology
Recent Comments