PHP 时间跳转代码:6点到12点重定向到特定页面
以下是将用户从早上 6 点到 12 点重定向到特定页面的 PHP 跳转代码:
$currentHour = date('H');
if ($currentHour >= 6 && $currentHour < 12) {
header('Location: http://example.com/morning-page.php');
exit;
} else {
// Redirect to a different page if the current time is not between 6am and 12pm
header('Location: http://example.com/other-page.php');
exit;
}
请注意,您需要将 'http://example.com/morning-page.php' 和 'http://example.com/other-page.php' 替换为您自己的网页 URL。此代码应该放在您想要进行时间检查和重定向的 PHP 文件的顶部。
原文地址: https://www.cveoy.top/t/topic/nQ7W 著作权归作者所有。请勿转载和采集!