Jump to content

Getting a page title


gerkintrigg

Recommended Posts

Hello.

I want to get the page title from the page that hosts a PHP script.

 

So if the script runs on index.php, I want the title of index.php to be output. I have a script that appears to do this, but it's just not working properly.

 

$my_page=curPageURL();
$filesource = $my_page;
$a = fopen($filesource,"r"); //fopen("html_file.html","r");
$string = fread($a,1024);
?>
<?php
if (eregi("<title>(.*)</title>",
$string, $out)) {
$outdata = $out[1];
}
echo $outdata;

Link to comment
https://forums.phpfreaks.com/topic/163262-getting-a-page-title/
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.