What are some best practices for including PHP scripts in multiple pages?

When including PHP scripts in multiple pages, it is best practice to create a separate PHP file that contains the common code and then include this file in each page where the code is needed. This helps to maintain code consistency, reduce redundancy, and make updates easier to manage.

// common.php
<?php
// Common PHP code here
?>

// page1.php
<?php include 'common.php'; ?>
// Page-specific code for page 1 here

// page2.php
<?php include 'common.php'; ?>
// Page-specific code for page 2 here