dpd66100 2016-10-30 12:40
浏览 36
已采纳

现在播出的剧本没有任何表现

I Have an on air script. I want to show who now on air. I have this script:

<?php

putenv("TZ=Europe/Amsterdam");
$h = date('G');
$d = date('w');

// Sunday
if ($d == 0 && $h >= 0 && $h < 9) { // Show Runs From Midnight til 6am
    $djname = 'Kick Radio'; //DJ Name
    $show = 'Kick Non Stop'; // Show description
}
elseif ($d == 0 && $h >= 0 && $h < 10) { // Show Runs From Midnight til 6am
    $djname = 'Kick Radio'; //DJ Name
    $show = 'Sunday Morning Songs'; // Show description
}
elseif ($d == 0 && $h >= 10 && $h < 0) { // Show Runs From Midnight til 6am
    $djname = 'Kick Radio'; //DJ Name
    $show = 'Kick Non Stop'; // Show description
}


// Monday
if ($d == 1 && $h >= 0 && $h < 0) { // Show Runs From Midnight til 6am
    $djname = 'Kick Radio'; //DJ Name
    $show = 'Kick Non Stop'; // Show description
}

echo '<h3>'.$show.'</h3>';

But it didn't show something. Only the <h3> tags. What's wrong with this code?

  • 写回答

1条回答 默认 最新

  • dtz55359 2016-10-30 13:00
    关注
    1. The problem is you give a chance to Sun $d == 0 and Mon $d == 1 only. You need conditions for other days of week too

    2. Hours $h can't be >= 0 & < 0 same time. So your 3rd and 4th conditions are impossible

    Start with following code

        if ($d == 0 && $h >= 0 && $h <= 6) {
            // Sunday midnight - 6 a.m.
        }
        elseif ($d == 0) {
            // remaining hours of Sunday
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错