Итак, мы пытаемся создать веб-сайт, который меняет целевую страницу в зависимости от сезона / сезона фестиваля.Я получил мой фрагмент кода для работы в демоверсии, но похоже, что маршрутизация не примет мою переменную или что-либо еще, кроме строки, подобной этой:
'views/mainpage.php'
Любые идеи о том, почемуэто не работает?
<?php
// Locate the file
$landing = array(
"on-season" => "mainpage.php",
"off-season" => "sacreddecade.php",
);
// What is today's date - number
$day = date("z");
// Days of season
$season_starts = date("z", strtotime("August 01"));
$season_ends = date("z", strtotime("September 30"));
// If test to see if it's season
if( $day >= $season_starts && $day <= $season_ends ) {
$season = "on-season";
} else {
$season = "off-season";
};
$file_path = $landing[$season];
//
$router = new Router(new Request);
$router->get('/', function() {
include_once("views/$file_path"); //<-- Change this to be root page instead of the login page...
});
Это ошибка, которую я получаю:
Notice: Undefined variable: file_path in C:\laragon\www\web3\index.php on line 33
Warning: include_once(C:\laragon\www\web3\views): failed to open stream: Permission denied in C:\laragon\www\web3\index.php on line 33
Warning: include_once(): Failed opening 'views/' for inclusion (include_path='.;C:/laragon/etc/php/pear') in C:\laragon\www\web3\index.php on line 33