cgm225 Posted February 18, 2008 Share Posted February 18, 2008 For my site I have been using a header.php and footer.php file to form a website "wrapper" in between which unique files are included. The header.php file includes the title and meta data, etc. So, for example, my main page would be generated by a file that includes three files: include_once "header.php"; include_once "frontpage.php" include_once "footer.php"; Or similarly, I could generate an e-mail page as such: include_once "header.php"; include_once "emailMe.php" include_once "footer.php"; However, here is my question. Is there a way, without using output buffering or templates (like Smarty), to set the webpage title (that found between the <title> tags within the header.php file) from the second included file/unique file found in between the header and footer? Right now I am doing this with output buffering, but I am trying to get away from that. Should I be creating my website "wrapper" a completely different way? Thank you all in advance! Link to comment https://forums.phpfreaks.com/topic/91617-setting-page-title-from-file-included-later-on/ Share on other sites More sharing options...
AndyB Posted February 18, 2008 Share Posted February 18, 2008 I normally handle that case like this: <?php $title = "This is the page title"; include_once "header.php"; include_once "emailMe.php" include_once "footer.php"; And then modify the header.php file to include this line in the appropriate location: echo "<title>". $title. "</title>"; Link to comment https://forums.phpfreaks.com/topic/91617-setting-page-title-from-file-included-later-on/#findComment-469264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.