What are the best practices for securing PHP files that are included in other scripts to prevent unauthorized access or exploitation?

To secure PHP files that are included in other scripts, it is important to place these files outside of the web root directory to prevent direct access. Additionally, you can use PHP's built-in functions like `define()` to define a constant in the main script and check for this constant in the included files to ensure they are being accessed properly.

// main script
define('INCLUDED', true);
include 'included_file.php';

// included_file.php
if (!defined('INCLUDED')) {
    die('Unauthorized access');
}

// Your code here