[Resolved]Getting <title> to use in HTML file,
Hello all,
Another small question! This time it might be difficult to explain but I'll try my best and ask question when you have any.
I want to get the HTML <title> value from a variable called &file,
Example:
The title of the current page is "Home"
I want to get title of File.php which is "Not Home" and show it in the content on home.php somewhere(By example via an Echo)
File.php gets included in the main content screen using a PHP Include.
I hope this makes it clear what I want to do and that I can get some help
Thank already!
Re: Getting <title> to use in HTML file,
declare it as a variable.
$title = "Home";
echo $title;
Re: Getting <title> to use in HTML file,
That would mean declaring it in each file, Which might not be possible
Re: Getting <title> to use in HTML file,
well if you have a main include file (say 'settings.php') all you need to do is include that on the top of every page.
and inside of settings.php have $title = "Home";
and on each page have echo $title;
Re: Getting <title> to use in HTML file,
PHP Code:
<?
$filename = "index.php";
$fhnd = fopen($filename, "r");
$fstr = fread($fhnd, filesize($filename));
fclose($fhnd);
$fstrA = split("<title>", $fstr);
$fstrB = split("</title>", $fstrA[1]);
$fstr = $fstrB[0];
echo $fstr;
?>
This should do the trick.
EDIT:
Tested it and made a slight change.
Works for me now.
Re: Getting <title> to use in HTML file,
Quote:
Originally Posted by TheBigB
PHP Code:
<?
$filename = "index.php";
$fhnd = fopen($filename, "r");
$fstr = fread($fhnd, filesize($filename));
fclose($fhnd);
$fstrA = split("<title>", $fstr);
$fstrB = split("</title>", $fstrA[1]);
$fstr = $fstrB[0];
echo $fstr;
?>
This should do the trick.
EDIT:
Tested it and made a slight change.
Works for me now.
And it does the trick wonderfully,Thank you.