Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic title for pages

Status
Not open for further replies.

DaRNCaT

Technical User
Dec 18, 2002
566
NZ
It must be late- but my mind has gone blank, and I can't find an example anywhere.
how do you make the <title> <?=$title?> </title>
then show up a title you specified- the title is part of an include, do I need to split the include and create a function- or can I call a function from outside the include??
I thought I had it nailed- but It's not working. Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
I think that the only way to include code is to specify the file name of the included code.

<?
include(&quot;mytitle.inc&quot;);
?> Clive
 
The way I do it is like this...

Main code...
<?
blah blah
$title = &quot;Title for this page is this&quot;;
include &quot;header.html&quot;;
blah blah
?>

header.html
<HTML><HEAD><TITLE>
<?echo $title?>
</TITLE></HEAD></HTML>

I'm sure there're other ways too.

-Rob
 
change the extension of header.html to header.php and it should work! --BB
 
why bother?

I like using .php extension for php code which will execute on include, .inc files for functions, and .html for files which are mostly html except for a few includes.... helps me organize my projects.

-Rob
 
ok, I got it to work- BUT, it's putting a number after my page title.... WHY!!??

code is (in the header include- header.inc)
blah blah
<title><?=print $DOC_TITLE?></title>
blah blah

and on the page I'm testing it out in (test.php)
<?php
$DOC_TITLE=&quot;My page title&quot;;
include (&quot;header.inc&quot;)?>

and the output is <title> My page title1 </title>

anyone know why? Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
actualy forget it- I'm just being dense and trying to use echo and print at the same time- maybe I should have a coffee.. o_O Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top