Ok, so my index.php has a php include for a header.php file. This header file contains the meta tag information and the style sheet information. Each other .php file I have also has the php include for the header. What I would like to do is to be able to set the <title>Title of page</title> on each individual page, (do this manually) but have that same title echoed in text at the top of the page. Is there a way to use my header.php file to find the title on the page it's included on, then echo that title as text later in the document.
Get Title of web page, print as text in body.
Collapse
X
-
are you thinking hard? don't do it.
just do simple
your header.php
Code:<title><?php echo $header;?></title>
Code:$header="Any Page"; include_once("header.php");
-
ok, so how does that work in this case..
<?php include("header .php") ?>
<header>
<title>The Title of my page</title>
</header>
<body>
<center>I want the title of my page printed here</center>
</body>
So I'm manually typing in the title for each page in the header information of each web page I create. Then I want to use that same title to echo the title at the top of the page as printed text. The header.php file is just basically code that I want on all of my pages. This way I don't have to keep adding it everytime I update or add another web page. Evenutally I will be using CSS to modify text on the pages so that's why I want to use my header.php to basically echo whatever I've set the title of the page to. I'm fairly new to php programming so thanks in advance for your patience.Comment
-
is it that hard?
Code:<?php include("header.php"); $Title="The Title of my page"; ?> <header> <title><?php echo $Title;?></title> </header> <body> <center><?php echo $Title;?></center> </body>
Comment
-
Comment