在特定日期用checkdate加载页面,如果没有重定向的话


load a page on a specific date with checkdate, if not redirect it

我想,我的页面只能在一个特定的日期加载。如果没有,重定向到另一个。我发现,这是可能的checkdate,但作为一个php新手,我不知道该怎么做。它应该像下面这样简单:Checkdate -> valid -> load pageCheckdate -> invalid ->重定向到example.php有人能给我指个方向吗?提前感谢!

function isValidDate($sd, $ed, $currentDate = null)
{
    if ($currentDate === null) {
        $currentDate = date('Y-m-d');
    }
    return ($currentDate >= $sd && $currentDate <= $ed);
}
$startDate = 'yyyy-mm-dd';
$endDate   = 'yyyy-mm-dd';
if (isValidDate($startDate, $endDate)) {
    // show page
} else {
    // redirect to example.php
}