What are the best practices for including header and footer files in PHP to maintain consistency across multiple pages?

To maintain consistency across multiple pages in PHP, it is best practice to use include or require statements to include header and footer files. By creating separate header and footer files containing common elements such as navigation menus, logos, and copyright information, you can easily update these elements across all pages by making changes in just one place.

<?php
// header.php
// Common header content
?>

<!DOCTYPE html>
<html>
<head>
    <title>Your Website Title</title>
    <!-- Include CSS and other head content here -->
</head>
<body>

<?php
// index.php
// Include header file
include 'header.php';
?>

<!-- Page-specific content -->

<?php
// Include footer file
include 'footer.php';
?>

</body>
</html>
```

```php
<?php
// footer.php
// Common footer content
?>

<footer>
    <p>© <?php echo date("Y"); ?> Your Website Name. All rights reserved.</p>
</footer>