473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get Title of web page, print as text in body.

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.
Apr 25 '12 #1

✓ answered by johny10151981

is it that hard?
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. include("header.php");
  3. $Title="The Title of my page";
  4.  ?>
  5. <header>
  6. <title><?php echo $Title;?></title>
  7. </header>
  8. <body>
  9. <center><?php echo $Title;?></center>
  10. </body>
  11.  

5 1906
johny10151981
1,059 1GB
are you thinking hard? don't do it.
just do simple
your header.php
Expand|Select|Wrap|Line Numbers
  1. <title><?php echo $header;?></title>
  2.  
your anypage.php
Expand|Select|Wrap|Line Numbers
  1. $header="Any Page";
  2. include_once("header.php");
  3.  
;)
Apr 25 '12 #2
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.
Apr 27 '12 #3
johny10151981
1,059 1GB
is it that hard?
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. include("header.php");
  3. $Title="The Title of my page";
  4.  ?>
  5. <header>
  6. <title><?php echo $Title;?></title>
  7. </header>
  8. <body>
  9. <center><?php echo $Title;?></center>
  10. </body>
  11.  
Apr 27 '12 #4
Well, I feel dumb. My brain must have been on vacation. I'm also learning PHP as I go too so I think I was being more complicated than I needed to be. Thanks.
Apr 30 '12 #5
johny10151981
1,059 1GB
We all had that stage of feeling dumb :) keep learning :)
Apr 30 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Mike | last post by:
I need to be able to pull the current <Title> tag from the header into the body of the html page. We started coding this with php, and we were able to get it working. However the entire page is...
1
by: Geert-Pieter Hof | last post by:
Hello, I'm using the Printer.PaintPicture method to print an image and I want to set the job title that the print manager will show. I already found out that this can be done by using the...
1
by: dave | last post by:
Hi There Is there any how can we attach html page into email body by just encoding url ? something like with oMsg .From="blah blah blah" .To="abc@xyz.com" .body=www.mysite.com/default.htm...
1
by: Mike John | last post by:
I want to send the page in the body of the email , just like the functionality of the send page in the browser explorer . I have tried the following systax <html> <body> <input type ="Button"...
6
by: HappyHippy | last post by:
More of a minor niggle than anything but how would I remove the aforementioned space? eg. strName = 'World' print 'Hello', strName, ', how are you today?' comes out as "Hello World , how are...
0
by: Cyberstar | last post by:
Hi, I'm a VB.net newbie with a newbie question. How can I print text from a form using Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As...
2
by: Chronos | last post by:
Hi all, Is it possible to print text file to a remote printer in C#? If so, can you tell me how? Thanks, Chronos
7
by: sheikh11 | last post by:
Dear sir, i would like to bring into your kind info dt i hve desires to embeb image or HTML in text body, & i hope that you will be me in this regard our coding are as below. Set JMail =...
2
by: bob | last post by:
Hi, I have a page that has a collection of things which it passes to a second 'print' page using a session variable. The print page has buttons for moving though the collection and the user ...
11
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.