Page Titles in PHP
Posted: Sat Apr 10, 2004 2:37 pm
I am very new to PHP, so I am trying to get some basic things down I want to do. I have my main file, index.php, which loads the content from main.php (unless another file is passed to it).
index.php :
then in main.php :
I just can't get it working.. when I view the output in my browser, it just shows <title></title> with nothing in it. I know it is loading up main.php properly, because there is some content in there, and it is showing up on the page just fine. Any ideas? Thanks!
Edit: Looking back, I did not make my problem as clear as I could of. What I am trying to do is take the page_title variable from main.php and make it the title of index.php.. so each file I am using will provide the title for the page.
index.php :
Code: Select all
<title><?php echo $page_title ?></title>
....
<?php
$page_location = $x . ".php";
if($x && file_exists($page_location)) {
include($page_location);
}
else {
include("main.php"); /* load if nothing else is passed */
}
?>Code: Select all
<?php $page_title = "This is the index"; ?>I just can't get it working.. when I view the output in my browser, it just shows <title></title> with nothing in it. I know it is loading up main.php properly, because there is some content in there, and it is showing up on the page just fine. Any ideas? Thanks!
Edit: Looking back, I did not make my problem as clear as I could of. What I am trying to do is take the page_title variable from main.php and make it the title of index.php.. so each file I am using will provide the title for the page.