I'm trying to build my own MVC as a practice and learning experience. So far, this is what I have (index.php):
<?php
require "config.php";
$page = $_GET['page'];
if( isset( $page ) ) {
if( file_exists( MVCROOT . "/$page.php" ) ) {
include "$page.php";
} else {
header("HTTP/1.0 404 Not Found");
}
}
?>
My problem here is, I can't use header to send to a 404 because the headers have been sent already. Should I just redirect to a 404.html
or is there a better way? Feel free to critique what I have so far (it's very little). I would love suggestions and ideas. Thanks!