3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!function_exists('cal_days_in_month')) { function cal_days_in_month($calendar, $month, $year) { return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31); } if (!defined('CAL_GREGORIAN')) { define('CAL_GREGORIAN', 1); } } //tests echo "----- Basic Tests ----\n"; var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 2014)); //31 var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 2014)); //28 var_dump(cal_days_in_month(CAL_GREGORIAN, 10, 2014)); //31 var_dump(cal_days_in_month(CAL_GREGORIAN, 11, 2014)); //30 echo "\n----- Leap Years ----\n"; //some leap years - expect 29 for all var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 1804)); var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 2000)); var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 2056)); var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 1994)); echo "\n----- Invalid tests ----\n"; //some invalid ones: var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 1)); var_dump(cal_days_in_month(CAL_GREGORIAN, 14, 2014)); //might be feb 2015? var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 2014000)); //the far far future? var_dump(cal_days_in_month(CAL_GREGORIAN, 0, 2014)); //do we handle zero? var_dump(cal_days_in_month(CAL_GREGORIAN, -1, 2014)); //how about negative? var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 0)); //and years? var_dump(cal_days_in_month(CAL_GREGORIAN, 1, -1)); //negative years?
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 13
filename:       /in/lFX5H
function name:  (null)
number of ops:  152
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'cal_days_in_month'
          2        DO_ICALL                                         $0      
          3        BOOL_NOT                                         ~1      $0
          4      > JMPZ                                                     ~1, ->13
    5     5    >   DECLARE_FUNCTION                                         'cal_days_in_month'
    9     6        DEFINED                                          ~2      'CAL_GREGORIAN'
          7        BOOL_NOT                                         ~3      ~2
          8      > JMPZ                                                     ~3, ->13
   10     9    >   INIT_FCALL                                               'define'
         10        SEND_VAL                                                 'CAL_GREGORIAN'
         11        SEND_VAL                                                 1
         12        DO_ICALL                                                 
   16    13    >   ECHO                                                     '-----+Basic+Tests+----%0A'
   17    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         16        FETCH_CONSTANT                                   ~5      'CAL_GREGORIAN'
         17        SEND_VAL_EX                                              ~5
         18        SEND_VAL_EX                                              1
         19        SEND_VAL_EX                                              2014
         20        DO_FCALL                                      0  $6      
         21        SEND_VAR                                                 $6
         22        DO_ICALL                                                 
   18    23        INIT_FCALL                                               'var_dump'
         24        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         25        FETCH_CONSTANT                                   ~8      'CAL_GREGORIAN'
         26        SEND_VAL_EX                                              ~8
         27        SEND_VAL_EX                                              2
         28        SEND_VAL_EX                                              2014
         29        DO_FCALL                                      0  $9      
         30        SEND_VAR                                                 $9
         31        DO_ICALL                                                 
   19    32        INIT_FCALL                                               'var_dump'
         33        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         34        FETCH_CONSTANT                                   ~11     'CAL_GREGORIAN'
         35        SEND_VAL_EX                                              ~11
         36        SEND_VAL_EX                                              10
         37        SEND_VAL_EX                                              2014
         38        DO_FCALL                                      0  $12     
         39        SEND_VAR                                                 $12
         40        DO_ICALL                                                 
   20    41        INIT_FCALL                                               'var_dump'
         42        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         43        FETCH_CONSTANT                                   ~14     'CAL_GREGORIAN'
         44        SEND_VAL_EX                                              ~14
         45        SEND_VAL_EX                                              11
         46        SEND_VAL_EX                                              2014
         47        DO_FCALL                                      0  $15     
         48        SEND_VAR                                                 $15
         49        DO_ICALL                                                 
   22    50        ECHO                                                     '%0A-----+Leap+Years+----%0A'
   24    51        INIT_FCALL                                               'var_dump'
         52        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         53        FETCH_CONSTANT                                   ~17     'CAL_GREGORIAN'
         54        SEND_VAL_EX                                              ~17
         55        SEND_VAL_EX                                              2
         56        SEND_VAL_EX                                              1804
         57        DO_FCALL                                      0  $18     
         58        SEND_VAR                                                 $18
         59        DO_ICALL                                                 
   25    60        INIT_FCALL                                               'var_dump'
         61        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         62        FETCH_CONSTANT                                   ~20     'CAL_GREGORIAN'
         63        SEND_VAL_EX                                              ~20
         64        SEND_VAL_EX                                              2
         65        SEND_VAL_EX                                              2000
         66        DO_FCALL                                      0  $21     
         67        SEND_VAR                                                 $21
         68        DO_ICALL                                                 
   26    69        INIT_FCALL                                               'var_dump'
         70        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         71        FETCH_CONSTANT                                   ~23     'CAL_GREGORIAN'
         72        SEND_VAL_EX                                              ~23
         73        SEND_VAL_EX                                              2
         74        SEND_VAL_EX                                              2056
         75        DO_FCALL                                      0  $24     
         76        SEND_VAR                                                 $24
         77        DO_ICALL                                                 
   27    78        INIT_FCALL                                               'var_dump'
         79        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         80        FETCH_CONSTANT                                   ~26     'CAL_GREGORIAN'
         81        SEND_VAL_EX                                              ~26
         82        SEND_VAL_EX                                              2
         83        SEND_VAL_EX                                              1994
         84        DO_FCALL                                      0  $27     
         85        SEND_VAR                                                 $27
         86        DO_ICALL                                                 
   29    87        ECHO                                                     '%0A-----+Invalid+tests+----%0A'
   31    88        INIT_FCALL                                               'var_dump'
         89        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         90        FETCH_CONSTANT                                   ~29     'CAL_GREGORIAN'
         91        SEND_VAL_EX                                              ~29
         92        SEND_VAL_EX                                              1
         93        SEND_VAL_EX                                              1
         94        DO_FCALL                                      0  $30     
         95        SEND_VAR                                                 $30
         96        DO_ICALL                                                 
   32    97        INIT_FCALL                                               'var_dump'
         98        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         99        FETCH_CONSTANT                                   ~32     'CAL_GREGORIAN'
        100        SEND_VAL_EX                                              ~32
        101        SEND_VAL_EX                                              14
        102        SEND_VAL_EX                                              2014
        103        DO_FCALL                                      0  $33     
        104        SEND_VAR                                                 $33
        105        DO_ICALL                                                 
   33   106        INIT_FCALL                                               'var_dump'
        107        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        108        FETCH_CONSTANT                                   ~35     'CAL_GREGORIAN'
        109        SEND_VAL_EX                                              ~35
        110        SEND_VAL_EX                                              1
        111        SEND_VAL_EX                                              2014000
        112        DO_FCALL                                      0  $36     
        113        SEND_VAR                                                 $36
        114        DO_ICALL                                                 
   34   115        INIT_FCALL                                               'var_dump'
        116        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        117        FETCH_CONSTANT                                   ~38     'CAL_GREGORIAN'
        118        SEND_VAL_EX                                              ~38
        119        SEND_VAL_EX                                              0
        120        SEND_VAL_EX                                              2014
        121        DO_FCALL                                      0  $39     
        122        SEND_VAR                                                 $39
        123        DO_ICALL                                                 
   35   124        INIT_FCALL                                               'var_dump'
        125        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        126        FETCH_CONSTANT                                   ~41     'CAL_GREGORIAN'
        127        SEND_VAL_EX                                              ~41
        128        SEND_VAL_EX                                              -1
        129        SEND_VAL_EX                                              2014
        130        DO_FCALL                                      0  $42     
        131        SEND_VAR                                                 $42
        132        DO_ICALL                                                 
   36   133        INIT_FCALL                                               'var_dump'
        134        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        135        FETCH_CONSTANT                                   ~44     'CAL_GREGORIAN'
        136        SEND_VAL_EX                                              ~44
        137        SEND_VAL_EX                                              1
        138        SEND_VAL_EX                                              0
        139        DO_FCALL                                      0  $45     
        140        SEND_VAR                                                 $45
        141        DO_ICALL                                                 
   37   142        INIT_FCALL                                               'var_dump'
        143        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        144        FETCH_CONSTANT                                   ~47     'CAL_GREGORIAN'
        145        SEND_VAL_EX                                              ~47
        146        SEND_VAL_EX                                              1
        147        SEND_VAL_EX                                              -1
        148        DO_FCALL                                      0  $48     
        149        SEND_VAR                                                 $48
        150        DO_ICALL                                                 
        151      > RETURN                                                   1

Function %00cal_days_in_month%2Fin%2FlFX5H%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lFX5H
function name:  cal_days_in_month
number of ops:  32
compiled vars:  !0 = $calendar, !1 = $month, !2 = $year
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        IS_EQUAL                                                 !1, 2
          4      > JMPZ                                                     ~3, ->22
          5    >   MOD                                              ~4      !2, 4
          6      > JMPZ                                                     ~4, ->9
          7    >   QM_ASSIGN                                        ~5      28
          8      > JMP                                                      ->20
          9    >   MOD                                              ~6      !2, 100
         10      > JMPZ                                                     ~6, ->13
         11    >   QM_ASSIGN                                        ~7      29
         12      > JMP                                                      ->19
         13    >   MOD                                              ~8      !2, 400
         14      > JMPZ                                                     ~8, ->17
         15    >   QM_ASSIGN                                        ~9      28
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~9      29
         18    >   QM_ASSIGN                                        ~7      ~9
         19    >   QM_ASSIGN                                        ~5      ~7
         20    >   QM_ASSIGN                                        ~10     ~5
         21      > JMP                                                      ->30
         22    >   SUB                                              ~11     !1, 1
         23        MOD                                              ~12     ~11, 7
         24        MOD                                              ~13     ~12, 2
         25      > JMPZ                                                     ~13, ->28
         26    >   QM_ASSIGN                                        ~14     30
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~14     31
         29    >   QM_ASSIGN                                        ~10     ~14
         30    > > RETURN                                                   ~10
    7    31*     > RETURN                                                   null

End of function %00cal_days_in_month%2Fin%2FlFX5H%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.98 ms | 1404 KiB | 19 Q