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 6254289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:09:20+00:00 2026-05-24T14:09:20+00:00

I have a header.php and a footer.php file. My HTML header is in header.php

  • 0

I have a header.php and a footer.php file. My HTML header is in header.php and I have an index.php file.

I’m using so (index.php):

require 'header.php';

$example_code = 'example';

︙

require 'footer.php';

And my header.php:

<html>
 <head>
  <title>
     ???
  <title>
  <meta name="description" content="???" /> 
   <meta name="keywords" content="???" /> 
 </head>
<body>
︙

I want to send some data from index.php to header.php to print it there (see the ???). I’m thinking of the header() function but I can’t see any example in the PHP manual.

  • 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-24T14:09:20+00:00Added an answer on May 24, 2026 at 2:09 pm

    The best thing you could do is separating logic from presentation. Using an MVC approach, where you take care of all logic in one file, and then display the outcome of what you’ve done in a presentation only layer.

    Besides that, if you want to keep your approach, what you simply have to do is to make assignments before header.php is included. So, suppose you want to change your page title, this is what you need to do:

    index.php

    <?php
    $title = 'My Page Title';
    $description = 'My meta description';
    $keywords = 'keyword list';
    include('header.php');
    
    ?>
    

    header.php

    <html>
     <head>
      <title>
         <?php echo $title; ?>
      <title>
      <meta name="description" content="<?php echo $description; ?>" /> 
       <meta name="keywords" content="<?php echo $keywords; ?>" /> 
     </head>
    <body>
    

    It’s as simple as that. Just keep in mind you can’t make assignments to a page/script, AFTER such has been included

    Again, though, I’m trying to answer you, not necessarily suggesting this approach. If your application has just a couple of pages, that’s ok. If it’s bigger (or going to be), something like the MVC pattern (two-step view pattern) is a better alternative IMHO.

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

Sidebar

Related Questions

I have a header.php and a footer.php file being included on the same page,
The setup: I have a standard .php file (index.php) that contains two includes, one
I have a bunch of static html files that share same header and footer.
I have developed a wordpress theme with header, footer, sidebar, index, page, single and
how do i style the html contents inside a php include file, using css?
I have a PHP script that pushes the headers to allow a file to
I have a c++ header file containing a class. I want to use this
At the moment, I have a base HTML template file. When ever I want
A few questions today :) I am using Codeigniter. I have a header view,
I have a middle size of website that share a common header/footer and almost

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.