drne47241 2017-07-10 09:54
浏览 15

根据星期几重定向网站

I would like to redirect my website on a certain day of a week. I've used the following code, but it won't work for me. What am I doing wrong?

<?php 
 $day = date("D");
 if( ($day == "Mon") )
  {
header("Location: monday.html");
  exit(); }
?>

</div>
  • 写回答

3条回答 默认 最新

  • donlih2986 2017-07-10 10:04
    关注

    Make it like this. This way you can easily adjust the Links and you don't even need if/else.

    $redirects = array(1 => 'monday.html',   // Link for Monday
                       2 => 'tuestday.html', // Link for Tuesday
                       3 => 'day.html',      // foo
                       4 => 'day.html',      // foo
                       5 => 'day.html',      // foo
                       6 => 'day.html',      // foo
                       7 => 'sunday.html');  // Link for Sunday
    
    header('Location: '.$redirects[date(N)]);
    exit();
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度