homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Include header.php
different titles on each page

 10:39 pm on Apr 6, 2003 (gmt 0)

I'm kind of new to php, so this might me a real simple question. I want to have a different title on every page. The way my pages are set up right now is to include my header.php file.

In my title on my header.php file i have something that looks like this <title>abc 123 <? echo $title;?></title>.

On all my other pages, on the top of each page, i have <? $title = ''; include "header.php";?>.

The way my site works now is that every page i go to has the same title and meta tags. I would like to change it so i can have different title on each page.

Im sure this is pretty simple to do, I just don't know how to do it.




 11:03 pm on Apr 6, 2003 (gmt 0)

Instead of setting $title to the empty string set it to an individual title before you include [php.net] header.PHP [php.net]. The included file will inherit the scope of the line calling include [php.net]. Thus $title will be different for each page.



 11:57 pm on Apr 6, 2003 (gmt 0)

I knew it would be simple. Thanks for the reply.


 4:25 am on Apr 7, 2003 (gmt 0)

Call it as a function, i.e.:

function do_html_header($title)
//formats a nice header
<title><? $title?></title></TITLE>
<H1>Your site name</H1>
//custom heading will be printed here via do_heading call

function do_html_footer()
// print an HTML footer

function do_heading($heading)
// print heading

You can include all 3 of these functions in one include or require statement. Coding your pages becomes simplicity itself.


do_html_header("Using Includes for Page Layout");


<P> Your content here </P>


Hope this is of some help.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved