Loading...
 
Gmail / Facebook Style Chat Application


Posted: Sunday 30th of September 2012

Get any Website Page Title From URL



This tutorial helps you to get the page title of any website via the website url.
The script of this tutorial takes the URL of a given page from which the page title is fetched.
To get started, just pass the url of the page that you wish to fetch its content to the getPage_Title_From_URL('url here') function and you are done.

code:

<?php
function getPage_Title_From_URL($pageURL)
{
      $readPG = fopen($pageURL, 'r');
      $x = 0;
      $specifiedPG = '';

      if ($readPG)
      {
            while (!feof($readPG) && ($x < 10))
            {
                  $specifiedPG .= fread($readPG, 8192);
                  $x++;
            }
            fclose($readPG);
      }
      preg_match("/<title.*?>[\n\r\s]*(.*)[\n\r\s]*<\/title>/", $specifiedPG, $pageTitleFromURL);
      if (isset($pageTitleFromURL[1]))
      {
            if ($pageTitleFromURL[1] == '')
            {
                  return $pageURL;
            }
            $pageTitleFromURL = $pageTitleFromURL[1];
            return trim($pageTitleFromURL);
      }
      else
      {
            return $pageURL;
      }
}
//Example function call
echo getPage_Title_From_URL('https://www.dvlottery.state.gov/');
?>


That's it guys...





Views Today: 0
Total Views: 800

Comments
0
OUR OBJECTIVE

Our objective is to reach a place where our services will be highly regarded by businesses from various industrial domains for building their innovative busines solutions with our cutting-edge technological expertise, interactive designs and uncompromised quality.

OUR MISSION

We aspire to help businesses ranging from startups to enterprises, who reach out to us with their requirements, in achieving great lengths, expanding their reach, upscaling their products, and generate a large user-base with our outstanding and cost-effective services.

Copyright © 2011 - 2024 | All Rights Reserved