1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Detecting HTML Page Title in PHP

Discussion in 'PHP' started by ProductivePC, May 29, 2004.

  1. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #21
    Here you go, this should do the trick:

    <?php
    
    //replace this with the url of your page
    $html = file_get_contents('http://forums.digitalpoint.com/index.php');
    
    
    if(preg_match('/<title>(.*)<\/title>/smU', $html, $matches)) {
    
    $title = $matches[1];
    
    echo $title;
    
    } else {
    
    echo("Tite tag could'nt be found");
    
    }
    ?>
    PHP:
    Example output:

    Webmaster Forum - Internet Marketing & Search Engine Forums
    Code (markup):

    SEMrush
     
    danx10, Jan 6, 2010 IP
    SEMrush