I found a lot of working codes to include page in page on Internet but I could not find a safe code. So I decided to create one myself. The pages will be only stored in folder /pages/ and whitelist seems to be a good option.Is the follow code safe?<?php$unsafe = $_GET['pagename'];$page = preg_replace('/[^A-Za-z0-9\-]/', '', $unsafe);if (empty($page)){include('pages/default.php');}$pages = array('default', 'pageone', 'pagetwo', 'another', 'last');if (isset($pages[$page])) {    include('pages/' . $page . '.php');} else {include('pages/error-404.php');}?>
PHP include page index.php?page=GET safety preg_replace
php;beginner;security;file system;dynamic loading