LOADING

由于本站是部署在GitHub上,如果你不会魔法可能会非常慢

若第二次加载还慢请开启浏览器缓存 浏览器默认开启

PHP课堂小练习

通过传入日期,计算那是星期几并输出(因为没有做HTML页面,所以这里用变量代替传入)

<?php
$year = 2023;
$month = 9;
$day = 19;
$week = date("w", mktime(0, 0, 0, $month, $day, $year));
switch($week){
    case 0:
        $weeks = "日";
        break;
    case 1:
        $weeks = "一";
        break;
    case 2:
        $weeks = "二";
        break;
    case 3:
        $weeks = "三";
        break;
    case 4:
        $weeks = "四";
        break;
    case 5:
        $weeks = "五";
        break;
    case 6:
        $weeks = "六";
        break;
}
echo "{$year}年{$month}月{$day}日是星期{$weeks}";
?>

作者:404_502
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0协议。转载请注明文章地址及作者