Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Include header.php

different titles on each page

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

10+ Year Member

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)

WebmasterWorld Senior Member 10+ Year Member

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)

10+ Year Member

I knew it would be simple. Thanks for the reply.
4:25 am on Apr 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

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.



Featured Threads

Hot Threads This Week

Hot Threads This Month