PHP Getting Title Of Remote Page – String Function

<?php
$file = fopen("http://www.php.net/", "r");if (!$file) {
    echo "<p>Unable to open remote file.\n";
    exit;
}
while (!feof($file)) {
    $line = fgets($file, 1024);    if (eregi("<title>(.*)</title>", $line, $out)) {
        $title = $out[1];
        break;
    }
}
fclose($file);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.