📜  PHP | cal_info( )函数

📅  最后修改于: 2022-05-13 01:56:23.015000             🧑  作者: Mango

PHP | cal_info( )函数

PHP中的 cal_info()函数是一个内置函数,用于返回有关指定日历的信息。 cal_info()函数返回一个包含 calname、month、abbrevmonth 和 maxdaysinmonth 以及 calsymbol 的数组。
它将日历作为参数并返回与指定日历相关的信息。

句法:

cal_info($calendar)

参数: PHP中的 cal_info()函数只接受一个参数$calendar 。此参数指定一个数字,表示您想了解的日历。以下是可用作此参数值的有效数字列表。

  • 0 = CAL_GREGORIAN
  • 1 = CAL_JULIAN
  • 2 = CAL_JEWISH
  • 3 = CAL_FRENCH

返回值:它返回有关指定日历的信息。

错误和异常

  1. 如果参数中未指定日历,则 cal_info()函数返回有关所有日历的信息。
  2. 要将日历指定为 cal_info()函数的参数,需要提及其各自的数值而不是日历名称,例如公历的“0”。

下面的程序说明了 cal_info()函数。

程序 1

PHP


PHP


输出:

Array
(
    [months] => Array
        (
            [1] => January
            [2] => February
            [3] => March
            [4] => April
            [5] => May
            [6] => June
            [7] => July
            [8] => August
            [9] => September
            [10] => October
            [11] => November
            [12] => December
        )

    [abbrevmonths] => Array
        (
            [1] => Jan
            [2] => Feb
            [3] => Mar
            [4] => Apr
            [5] => May
            [6] => Jun
            [7] => Jul
            [8] => Aug
            [9] => Sep
            [10] => Oct
            [11] => Nov
            [12] => Dec
        )

    [maxdaysinmonth] => 31
    [calname] => Gregorian
    [calsymbol] => CAL_GREGORIAN
)

方案二

PHP


输出:

Array
(
    [months] => Array
        (
            [1] => Tishri
            [2] => Heshvan
            [3] => Kislev
            [4] => Tevet
            [5] => Shevat
            [6] => Adar I
            [7] => Adar II
            [8] => Nisan
            [9] => Iyyar
            [10] => Sivan
            [11] => Tammuz
            [12] => Av
            [13] => Elul
        )

    [abbrevmonths] => Array
        (
            [1] => Tishri
            [2] => Heshvan
            [3] => Kislev
            [4] => Tevet
            [5] => Shevat
            [6] => Adar I
            [7] => Adar II
            [8] => Nisan
            [9] => Iyyar
            [10] => Sivan
            [11] => Tammuz
            [12] => Av
            [13] => Elul
        )

    [maxdaysinmonth] => 30
    [calname] => Jewish
    [calsymbol] => CAL_JEWISH
)

参考:
http:// PHP.net/manual/en/函数.cal-info。 PHP