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

  • Home
  • SEARCH
  • 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 7403195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:59:48+00:00 2026-05-29T04:59:48+00:00

So I have this PHP website that I am working on that using templates.

  • 0

So I have this PHP website that I am working on that using templates. Any page is divided into three parts: header, content and footer. Each part is represented by a .php file.

Header:

<html>
<head><link_to_some_css /></head>
<body>
<div id="menuBar">
    xxx
</div>

Content:

<?php include("header.php") ?>
    <div id="someHTMLContent">xxx</div>
    <!-- 
        How do I link an external CSS stylesheet from within here?
    -->
<?php include("footer.php") ?>

Footer:

</body></html>

The <link> tag should resides within the <head>, but being within content.php I have no access to the head of the html.

Sorry if this has been asked, but I am a little new to implementing a framework-less PHP project in an MVC architecture (hence trying to separate CSS JavaScript PHP files for a better structure)

  • 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-29T04:59:49+00:00Added an answer on May 29, 2026 at 4:59 am

    If you want something included in the header then make it a global variable before including.

    $header = 'Add something to the head tag';
    include('header.php');
    

    In the header.php:

    <head>
    <?php
    if (isset($header)) {
        echo $header;
    }
    ?>
    <!-- Add global headers -->
    </head>
    

    You could add a more robust solution by defining functions to create CSS tags given a link and then add them into the global $header string. These would need to be included from a core.php file included before the header include.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to upload a given image using Amazon S3 I have this PHP:
I'm working on my first website using php. I came up with a good
I am currently working on a website and lately have been using GD with
I am working on a website that involves automatically populating a select box using
I have a webapp written in PHP using a MySQL database backend. This question
I am working on a website that passes all PHP scripts through a single
I have been using a php sql system to manage images on my website.
I'm working on a website using friendly URLs. We want to have www.website.com/johndoe go
I am working on a simplistic website using PHP, a language I haven't touched
I'm using PHP and xPath to crawl into a website I own (just crawl

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.