<?php
function view(string $viewName, array $args = []): bool
{
$viewPathParts = explode(".", $viewName);
$viewPath = "";
foreach ($viewPathParts as $pathPart){
$viewPath .= "/" . $pathPart;
}
$viewPath = "resources/views" . $viewPath . ".php";
if(file_exists($viewPath)){
extract($args);
include $viewPath;
return true;
}else{
echo "La vue " . $viewName . " est introuvable.";
return false;
}
}