Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP Header Include

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29342
    spate1y
    Member

    I am currently making my own little web app and I am using PHP’s include function to add a header.php file to all my pages (basically like WordPress). Now my only problem is how do I give different page titles to each page. What is the easiest and most efficient way to do this?

    Thanks!

    #77758
    Rob MacKay
    Participant

    Well that depends on how you are making your pages? Are you using PHP or just a standard HTML file that includes the header at the top of each page.

    Will the address be something like website.com/?page=1 or website.com/about.php

    #77841
    eXo
    Member

    You can use the following:

    Index.php

    Code:

    <?php
    $PageTitle
    = “Index”;
    include(
    ‘header.php’);
    ?>

    header.php

    Code:

    <title><?php echo $PageTitle?></title>
    #78271
    spate1y
    Member

    Robskiwarrior: Both the header file and all the standard page files are .php. The url would end with about.php.

    eXo: Your method is good :)

    Robskiwarrior, if you have any other methods that I could try, I would love to see!

    #78289
    Capt Otis
    Member

    eXo’s method is the easiest and fastest that I know of for the type of pages you have. Now if you had a page that rendered differently depending on certain circumstances and wanted to reflect those in the title, I would do almost the same thing except maybe grabbing another variable to add to the title.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.