PHP cal_info() 函数返回指定日历的信息。可用作日历的不同日历的名称如下:
- 0 或 CAL_GREGORIAN - 公历
- 1 或 CAL_JULIAN -儒略历
- 2 或 CAL_JEWISH - 犹太历
- 3 或 CAL_FRENCH - 法国大革命历法
如果没有日历指定后,此函数以数组形式返回所有支持的日历的信息。
语法
cal_info(calendar)
参数
calendar | 可选。 指定要为其返回信息的日历。如果没有指定日历,则返回所有日历的信息。 |
返回值
返回包含下面列出的日历信息的数组:
- 月份
- 缩写月份
- maxdaysinmonth
- calname
- calsymbol
异常
无。示例:
下面的示例显示了cal_info()函数的用法。
<?php
//显示信息
//公历
print_r(cal_info(0));
?>
上述代码的输出将是:
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
//显示信息
//犹太历
print_r(cal_info(CAL_JEWISH));
?>
上述代码的输出将是:
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
)