因此,我们正在尝试创建一个网站,该网站会根据节日的淡季/淡季来更改目标网页。 我已将代码段用于演示,但似乎路由将不接受我的变量,或诸如此类的字符串以外的其他字符串:
length/2
关于它为什么不起作用的任何想法?
'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...
});
答案 0 :(得分:2)