php cal_info()函数返回有关指定历法的信息

原创 国哥笔记  2019-03-23 17:30  阅读 292 views 次

cal_info()函数定义及用法

在php中,cal_info()函数是使用来返回有关指定历法的信息,返回值为一个数组,数组中包含了calname、calsymbol、month、abbrevmonth和maxdaysinmonth。

cal_info()函数用法很简单,就只有一个参数,该参数规定一个指示历法的数字或常量。可能的数值和常量有0(CAL_GREGORIAN)、1(CAL_JULIAN)、2(CAL_JEWISH)、3(CAL_FRENCH)。cal_info()函数中参数还可以被省略,如果被省略,则该函数返回有关所有历法的信息。

cal_info()函数语法格式

cal_info(calendar);

参数说明

  • calendar:可选参数(如果被省略,则该函数返回有关所有历法的信息),规定一个指示历法的数字,还可以使用常量,可能的数字和对应的常量如下:

0 = CAL_GREGORIAN

1 = CAL_JULIAN

2 = CAL_JEWISH

3 = CAL_FRENCH

实例:

<?php
var_dump(cal_info(CAL_GREGORIAN));
//等同于var_dump(cal_info(0));
?>
php的windows版本已内建了对日历扩展的支持,但如果是 Linux 版本,就必须通过--enable-calendar编译php,日历函数才能工作。

运行结果截图:

cal_info()函数返回有关指定历法的信息

运行输出结果:

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 Calendar日历函数大全

本文地址:https://www.ggbiji.com/php-cal_info.html
版权声明:本文为 国哥笔记 原创/整理文章,欢迎分享,转载请注明出处!

发表评论


表情