Jump to content

Obtaining Page Title


Maverickb7

Recommended Posts

I was wondering if someone could tell me the easiest way to obtaining the page title of a specific url? I've tried to use fopen and those functions but I got the below error.

 

Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /home/web/ute.php on line 2
Link to comment
https://forums.phpfreaks.com/topic/43773-obtaining-page-title/
Share on other sites

Alright i'm trying to get my host to enable url_fopen but until then I still have to find a work around. I'm searching for these terms on google and I'm not coming up with many helpful examples. What would I search for using google? Sorry if I'm coming off as a n00b, just trying to get my head in this stuff.

Link to comment
https://forums.phpfreaks.com/topic/43773-obtaining-page-title/#findComment-212556
Share on other sites

I have write a scripts

 

Test it

 

<?php

ob_start();

readfile('http://www.yahoo.com');

$con = ob_get_clean();

$filecontents = htmlentities($con);

echo substr($filecontents,strpos($filecontents,"<title>")+13,(strpos($filecontents,"</title>")-strpos($filecontents,"<title>")-13));

 

?>

Link to comment
https://forums.phpfreaks.com/topic/43773-obtaining-page-title/#findComment-212581
Share on other sites

// For Greter version of PHP

 

function get_string_between($string, $start, $end){

        $string = " ".$string;

        $ini = strripos($string,$start);

        if ($ini == 0) return "";

        $ini += strlen($start); 

        $len = strripos($string,$end,$ini) - $ini;

        return substr($string,$ini,$len);

}

ob_start();

readfile('http://www.rediff.com');

$con = ob_get_clean();

$filecontents = htmlentities($con);

echo get_string_between($filecontents,"<title>","</title>");

Link to comment
https://forums.phpfreaks.com/topic/43773-obtaining-page-title/#findComment-212739
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.