Are there any security implications to consider when setting a default main page in PHP?

Setting a default main page in PHP can potentially expose sensitive information or create security vulnerabilities if not done carefully. It is important to ensure that the default main page does not reveal any sensitive information about the server or application, and to properly sanitize user input to prevent against potential security risks such as SQL injection or cross-site scripting attacks.

<?php
// Set default main page to index.php
$defaultMainPage = 'index.php';

// Validate user input for main page
$mainPage = isset($_GET['main_page']) ? $_GET['main_page'] : $defaultMainPage;
$mainPage = preg_replace('/[^a-zA-Z0-9_\-]/', '', $mainPage);

// Include the main page
include $mainPage;
?>