为什么这个PHP switch语句会跳过" Sunday"?

时间:2015-12-14 03:42:53

标签: php datetime switch-statement

周六晚上午夜过夜,由于某种原因它会在周日跳过!每隔一天显示就好了。为什么它会在周日跳过?

设置此switch语句以迭代日期并显示一些内容的最佳方法是什么?

<?php

date_default_timezone_set('America/Phoenix');

$weAreOpen = areWeOpen(date("w"));

function areWeOpen($day)
{
    $day = (int)$day;
    $timenow = date('g:i a');

    switch ($day) {
        case ($day == 0):
            echo "<h1>I cherish your love at <span       class=\"timeColor\">$timenow</span> this Sunday0!</h1>
                <br>
                <img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I  Beat For You!\" title=\"I Beat For You!\">";
            break;

        case ($day == 1):
            echo " <h1>It's definately <span  class=\"timeColor\">$timenow</span> Monday1 and I love you even today! :)</h1>
                <br>
                <br>
                <img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I Beat For You!\" title=\"I Beat For You!\">";
            break;

        case ($day == 2):
            echo "<h1>It's <span class=\"timeColor\">$timenow</span> Tuesday2!! I love you..... :)<br>Scan or click this to hear love message</h1>
                <a href=\"http://boxoflove.us/audio/honeyloveyou.mp3\"  target=\"_blank\">
                <img class=\"loveaudio\" alt=\"Who I Am\"  src=\"http://boxoflove.us/lovetime/images/qr/honeyloveyouqr.png\" title=\"Who I  Am\" /></a>
                <br>
                <br>
                <iframe width=\"320\" height=\"280\" src=\"https://www.youtube.com/embed/exgHwy-Q5ik?rel=0\" frameborder=\"0\" allowfullscreen></iframe>
                <br>
                <br>
                <audio id=\"audio1\" src=\"audio/siren.mp3\" controls></audio>
                <br><img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I Beat For You!\" title=\"I Beat For You!\">";
            break;

        case ($day == 3):
            echo "<h1>It's <span class=\"timeColor\">$timenow</span> Wednesday3 and the love I have for you seems to be increasing!</h1>
                <br>
                <br>
                <img src=\"http://mobilesavior.com/images/mobilesaviorhomeqr200.jpg\" alt=\"Home QR\"><br><img class=\"boximg\" src=\"images/boxoflove5.jpg\" alt\"Box of love\"     />
                <br>
                <audio id=\"audio1\" src=\"siren.mp3\" controls></audio>
                <br><img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I Beat For You!\" title=\"I Beat For You!\">";
            break;

        case ($day == 4):
            echo "<h1>It's <span class=\"timeColor\">$timenow</span> Thursday4, and I love you!</h1>
                <br>
                <br>
                <img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I Beat For You!\" title=\"I Beat For You!\">";
            break;

        case ($day == 5):
            echo "<h1>Hello! It's <span class=\"timeColor\">$timenow</span> Friday5! I am definately in love with you, but I am also your friend.</h1>
                <br>
                <br>
                <img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I Beat For You!\" title=\"I Beat For You!\">";
            break;

        case ($day == 6):
            echo "<h1>It's <span class=\"timeColor\">$timenow</span>        Saturday6, hooray!! I love you! Hooray!! ;)</h1>
                <br>
                <img class=\"heart2\" src=\"/images/redheart300s.png\" alt=\"I  Beat For You!\" title=\"I Beat For You!\">";
            break;
    }
}
?>

0 个答案:

没有答案
相关问题