Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4082716
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:13:19+00:00 2026-05-20T18:13:19+00:00

Something basic that i don’t understand: I have header.php with navigation bar for my

  • 0

Something basic that i don’t understand:

I have header.php with navigation bar for my site. Inside it, there’s a <head>...</head> section.

Now, in each other page of my site, I’m using require_once 'header.php' so that each page will show the navigation bar. But, I need also specific <head>...</head> sections to the different page.

For example, in page customers.php, I’m using <script>...</script> to include the jQuery library. I don’t need to include it in other pages.

Now, searching the web I see that multiple head tags is wrong syntax.

So, how can anyone:

  1. avoid multiple “head” tags
    WHILE
  2. separating his work to different PHP files and including them ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:13:19+00:00Added an answer on May 20, 2026 at 6:13 pm

    You have to change your page structure and employ templates.
    Instead of loading header at the top of the code, you have to do it at the bottom!
    And page code should output not a word, but collect all data in variables.
    And only after that output can be started by calling template.

    A example layout is going to be like this:

    First. page itself.
    it outputs nothing but only gather required data and calls a template:

    <?
    //include our settings, connect to database etc.
    include dirname($_SERVER['DOCUMENT_ROOT']).'/cfg/settings.php';
    //getting required data
    $DATA=dbgetarr("SELECT * FROM links");
    $pagetitle = "Links to friend sites";
    //etc
    //and then call a template:
    $tpl = "links.php";
    include "template.php";
    ?>
    

    Next, template.php which is your main site template, consists of your header and footer:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>My site. <?=$pagetitle?></title>
    </head>
    <body>
    <div id="page">
    <? include $tpl ?>
    </div>
    </body>
    </html>
    

    And, finally, links.php is the actual page template:

    <h2><?=$pagetitle?></h2>
    <ul>
    <? foreach($DATA as $row): ?>
    <li><a href="<?=$row['link']?>" target="_blank"><?=$row['name']?></a></li>
    <? endforeach ?>
    <ul>
    

    easy, clean and maintainable.

    there are many advantages in such approach:

    • as requested, you can populate header with actual page-relevant data.
    • HTTP headers can be sent as well, before any output. It includes cookies, sessions, cache-control and many more.
    • it’s 2011 today. AJAX era. You may wish change your code to return JSONed data instead of whole HTML page. It’s going to be easy using such layout.
    • Imagine you’re going to create very similar site with just different design. You will have to change only templates and don’t touch engine files. That’s really great advantage of using templates.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm guessing there's something really basic about C# inheritance that I don't understand. Would
Basic question here - I have many lines of code that look something like:
I'm sure this is something really basic that I don't know but how do
I have a DLL in C# that encrypts and decrypts string texts (something basic),
This is probably a pretty basic question, but just something that I wanted to
I feel like there's something rather basic I'm missing here, which I previously thought
Alright, so this is something really basic, and I know that when someone tells
I have a basic class that I extend fairly often. I thought it would
New to WPF, am trying to do something basic (I think!). I have a
We have a framework that defines many interfaces and some basic default implementations. Let's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.