PHP Include question

Discussion in 'HTML & Website Design' started by lowprofilejoe, Dec 29, 2007.

  1. #1
    I have all my sites/pages setup using (php) includes, as much and where ever possible. I have an include called headerinfo.inc which has meta’s, javascript, css, icons, etc. Obviously I don’t put title, description and keywords in here.

    So here’s what I want to happen. I would like to define the title tag in this file. I want it to look for a variable (to exist) in each independent page. The variable will be displayed in the title. I also want to concatenate the site name. I’m sure this is wrong, but this should give you an idea of what I’m thinking:

    <title>$titleDesc + Pre Defined Site Name</title>

    I guess my question(s) are: What does the code look like for the title, what does it look like on the page level and where do I put it on the page?

    Thanks in advance!

    Joe
     
    lowprofilejoe, Dec 29, 2007 IP
  2. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <?php include('headerinfo.inc'); ?>
    <html>
    <head>
    <title><?php echo($titleDesc); ?> Pre defined site name</title>
    </head>
    ...[I]The Rest Of Your HTML Page[/I]
    
    Code (markup):
    That code would include your "headerinfo.inc" page and then all you have to do is put the "$titleDesc" variable in the "headerinfo.inc" file and it will display on the title for the HTML page. The <title></title> tag goes between the <head> & </head> tags as shown above.

    Hope this answers your question(s).
     
    jmhyer123, Dec 29, 2007 IP
  3. lowprofilejoe

    lowprofilejoe Active Member

    Messages:
    253
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Wow, thanks so much for the quick response. That wasn't exactly what I was looking for. I'm already calling in the headerinfo.inc (<?php include('headerinfo.inc'); ?>), but I would like to include <?php echo($titleDesc); ?> Pre defined site name</title> as part of headerinfo.inc.

    I would like to define $titleDesc on each page. How do I define/declare that variable and where?

    Thanks again
     
    lowprofilejoe, Dec 29, 2007 IP
  4. T.Ace

    T.Ace Peon

    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    add after <?php
     
    T.Ace, Dec 29, 2007 IP