I have the following code I found on the internet, I'm not very good with php but I would have a way to optimize the following code:
<?php
$pages = array(
"home" => array(
"title" => "Title name page",
"display" => "home.php",
"description" => "Description name page",
),
"order" => array(
"title" => "Title name page",
"display" => "order.php",
"description" => "Description name page",
),
"contacto" => array(
"title" => "Title name page",
"display" => "contacto.php",
"description" => "Description name page",
),
404 => array(
"title" => "Page Not Found",
"display" => "404.php",
"description" => "The page you requested was not found!",
)
);
require('config.php');
if(isset($_GET["page"])) {
if (isset($pages[$_GET["page"]])) {
$page = $_GET["page"];
$title = $pages[$page]["title"];
$display = $pages[$page]["display"];
$description = $pages[$page]["description"];
include('header.php');
include($display);
include('footer.php');
} else {
$page = 404;
$display = $pages[$page]["display"];
$title = $pages[$page]["title"];
$description = $pages[$page]["description"];
include('header.php');
include($display);
include('footer.php');
}
} else {
$page = "home";
$display = $pages[$page]["display"];
$title = $pages[$page]["title"];
$description = $pages[$page]["description"];
include('header.php');
include($display);
include('footer.php');
}
?>
You believe that there is any way to optimize and includes many not use header / footer?