Besides just using include() or include_once() to include the header and footer, one thing I have found useful is being able to have a custom page title or custom head tags to be included for each page, yet still have the header in a partial include. I usually accomplish this as follows:

In the site pages:

<?php

$PageTitle="New Page Title";

function customPageHeader(){?>
  <!--Arbitrary HTML Tags-->
<?php }

include_once('header.php');

//body contents go here

include_once('footer.php');
?>

And, in the header.php file:

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title><?= isset($PageTitle) ? $PageTitle : "Default Title"?></title>
    <!-- Additional tags here -->
    <?php if (function_exists('customPageHeader')){
      customPageHeader();
    }?>
  </head>
  <body>

Maybe a bit beyond the scope of your original question, but it is useful to allow a bit more flexibility with the include.

Answer from William on Stack Overflow
🌐
PHP
php.net › manual › en › function.header.php
PHP: header - Manual
By default it will replace, but if you pass in false as the second argument you can force multiple headers of the same type. For example: <?php header('WWW-Authenticate: Negotiate'); header('WWW-Authenticate: NTLM', false); ?>
🌐
W3Schools
w3schools.com › php › func_network_header.asp
PHP header() Function
HTML Reference CSS Reference JavaScript Reference SQL Reference Python Reference W3.CSS Reference Bootstrap Reference PHP Reference HTML Colors Java Reference AngularJS Reference jQuery Reference · HTML Examples CSS Examples JavaScript Examples How To Examples SQL Examples Python Examples W3.CSS Examples Bootstrap Examples PHP Examples Java Examples XML Examples jQuery Examples
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-header-function
PHP | header() Function - GeeksforGeeks
July 11, 2025 - It denotes the header should replace previous one or add a second header. The default value is True (will replace). If $replace value is False then it force multiple headers of the same type. $http_response_code: It is an optional parameter. It forces the HTTP response code to the specified value (PHP 4.3 and higher).
🌐
Envato Tuts+
code.tutsplus.com › home › wordpress › theme development
The header.php File: What Needs to Go in It and What Doesn't | Envato Tuts+
September 22, 2022 - Let's begin with the functions.php file. We've added these lines in the file: The following line removes the meta generator tag because it displays the WordPress version number. It's not wise to expose your WordPress version number publicly, which could make you vulnerable to version-related attacks. Thus, we've removed it. In this case, we've created the enqueue_styles function to add link tags to the header.php file.
🌐
Tutorialspoint
tutorialspoint.com › php › php_function_header.htm
PHP Network header() Function
Headers are important because they inform the browser how to handle a request or response. For example, headers can be used to redirect a visitor to another page or to set the HTTP ...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › php tutorial › php header()
PHP header() | Complete Guide to PHP header() with Examples
March 31, 2023 - ... <?php header('WWW-Authenticate: Negotiate'); echo ('header has been changed to WWW-Authenticate: Negotiate'); echo "\n"; header('WWW-Authenticate: NTLM', false); echo ('header has been changed to WWW-Authenticate: NTLM'); ?>
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Simplilearn
simplilearn.com › home › resources › software development › header in php: the ultimate guide to header function
Header in PHP: The Ultimate Guide to Header Function
September 11, 2025 - The header in PHP is a built-in function for sending a raw HTTP header. Learn how to 📥 download files using a header function and much more. Start now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Find elsewhere
🌐
Javatpoint
javatpoint.com › php-header
PHP header() - javatpoint
PHP header() with examples, php file, php session, php date, php array, php form, functions, time, xml, ajax, php mysql, regex, string, oop, addslashes(), addcslashes() etc.
🌐
PHPpot
phppot.com › php › php-header
PHP header - PHPpot
PHP header and related functions syntax, usage with simple examples for setting the request and metadata via header.
🌐
GitHub
gist.github.com › irazasyed › 5788118
PHP HTTP Headers (Examples) · GitHub
PHP HTTP Headers (Examples). GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › WordPress › WordPress › blob › master › wp-content › themes › twentytwelve › header.php
WordPress/wp-content/themes/twentytwelve/header.php at master · WordPress/WordPress
<a class="screen-reader-text skip-link" href="#content"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a> <header id="masthead" class="site-header"> <hgroup> <?php · $is_front = !
Author   WordPress
🌐
Edureka
edureka.co › blog › header-location-in-php
Header Location In PHP | PHP Header Location Edureka
February 25, 2025 - This article on Header Location In PHP will introduce to header function in PHP along with the practical demonstration for the same.
🌐
Kirupa
kirupa.com › web › header.htm
kirupa.com - Header in PHP
I've needed the header function in php so many times I figured I'd write a tutorial on it. This tutorial should help you do most of the things that the header function is capable of. Simply put, the php header function will send a http header to the browser · Here is How: The following steps ...
🌐
Pi My Life Up
pimylifeup.com › home › how to use the php header function
How to Use the PHP header Function - Pi My Life Up
November 4, 2024 - In the example below, we use the location header to redirect anyone who hits our PHP script to the Google search engine.
🌐
Team Treehouse
teamtreehouse.com › community › php-include-headerfooter-best-practice
PHP include header/footer best practice (Example) | Treehouse Community
June 20, 2014 - <!DOCTYPE html> <html> <head> <title></title> <body> <?php include("header.php"); ?> <div id="page-content"> </div> <?php include("footer.php"); ?> </body> </html>
🌐
TutorialsPoint
tutorialspoint.com › what-is-header-function-in-php
What is header() function in PHP?
August 30, 2019 - Headers are important because they inform the browser how to handle a request or response. For example, headers can be used to redirect a visitor to another page or to set the HTTP ...