1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Get the title of the url

Discussion in 'PHP' started by coderzone, Aug 12, 2006.

  1. coderzone

    coderzone Super Moderator


    I am looking for a code snippet that can get me the title of the url I enter.

    something like if I pass

    It should return Go4Expert - Begining with PHP

    I have checked the internet and seen that curl of php can be useful but could not use it in a very good sense as I am not a PHP expert.
  2. pradeep

    pradeep Team Leader

    We can use Regular Expressions to get the title of a page, see the PHP code snippet below which extracts the title of page who's URL you specify.

    $url "http://www.go4expert.com/showthread.php?t=2";
    $file file($url);
    $file implode("",$file);

    "The title of $url is <b>$m[1]";
    "The page doesn't have a title tag";
  3. shabbir

    shabbir Administrator Staff Member

    I have added an extra bit of condition
    if (@fclose(@fopen($rightlink"r")))
    so that if the link is not reachable you dont have to open the file.

Share This Page