What are best practices for securely including PHP files in the index and handling parameters within the PHP scripts?

When including PHP files in the index, it is important to ensure that the files are included securely to prevent any potential vulnerabilities. One best practice is to use absolute paths instead of relative paths to include files. Additionally, when handling parameters within PHP scripts, always sanitize and validate user input to prevent SQL injection and cross-site scripting attacks.

<?php
// Securely include PHP files using absolute paths
include_once $_SERVER['DOCUMENT_ROOT'] . '/path/to/file.php';

// Sanitize and validate parameters
$param = isset($_GET['param']) ? filter_var($_GET['param'], FILTER_SANITIZE_STRING) : '';