PHP |复活节_days()函数

easter_days()函数是PHP中的一个内置函数,它返回给定年份中3月21日之后的复活节天数。如果没有给出年份,则将当前年份作为默认值。

null

语法:

easter_days( $year, $method )

参数: 该函数接受两个可选参数,如下所示:

  1. 美元一年 此参数指定年份。如果未传递任何参数,则将当前年份作为默认值。
  2. $method- 此参数允许您根据其他日历计算复活节日期。如果 $method 设置为CAL_EASTER_ROMAN,在1582-1752年间使用公历。

返回值: 该函数返回3月21日之后的天数,即复活节在给定年份中的天数。当没有 美元一年 作为参数通过。当前年份作为默认年份,并返回当前年份3月21日之后的天数。

例如:

Input :  $year = 2018
Output : 11

Input : $year = 2017
Output : 26  

Input: $year = 2015 $method = CAL_EASTER_ROMAN
Output : 15  

下面的程序演示了复活节()函数的用法:

项目1: 下面的程序解释了easter_days()函数在未传递任何参数时的工作原理。

<?php
// PHP program to demonstrate the
// easter_days() function
// when no parameter is passed
echo easter_days(), "" ;
// verified by passing current year
$year = 2018;
echo easter_days( $year );
?>


输出:

11
11

项目2: 下面的程序解释了easter_days()函数在以下情况下的工作: 美元一年 参数被传递

<?php
// PHP program to demonstrate the
// easter_days() function
// when $year parameter is passed
$year = 2015;
// no of days for Easter after march 21 of year 2015
echo easter_days( $year ), "" ;
// the Easter date of year 2015
echo date ( "M-d-Y" , easter_date( $year ));
?>


输出:

15
Apr-05-2015

方案3: 下面的程序解释了在传递这两个参数时easter_days()函数的工作原理。

<?php
// PHP program to demonstrate the
// easter_days() function
// when both parameters are passed
$year = 2014;
// no of days for Easter after march 21 of year 2014
// of Gregorian Calendar
echo easter_days( $year , CAL_EASTER_ROMAN), "" ;
?>


输出:

30

参考: http://php.net/manual/en/function.easter-days.php

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享