uri, $routes)){ // If it exists, require (include and execute) the file corresponding to the route require $routes[$uri]; }else{ // If the route doesn't exist, call the abort method to handle the error $this->abort(); } } /** * Method to handle HTTP errors * Default is 404 - Not Found */ public function abort($code = 404){ // Set the HTTP response code to the specified value http_response_code($code); // Include and execute the corresponding error view (e.g., "views/404.php") require "views/{$code}.php"; // Terminate the script execution die(); } } // $routes = [ // '/' => 'controllers/index.php', // '/about' => 'controllers/about.php', // '/contact' => 'controllers/contact.php', // ]; // $router = (new Router)->routeToController($routes); ?>