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 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 //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)); //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/ek0oZ
function name:  (null)
number of ops:  149
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                                                 
   17    13    >   INIT_FCALL                                               'var_dump'
         14        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         15        FETCH_CONSTANT                                   ~5      'CAL_GREGORIAN'
         16        SEND_VAL_EX                                              ~5
         17        SEND_VAL_EX                                              1
         18        SEND_VAL_EX                                              2014
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
   18    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         24        FETCH_CONSTANT                                   ~8      'CAL_GREGORIAN'
         25        SEND_VAL_EX                                              ~8
         26        SEND_VAL_EX                                              2
         27        SEND_VAL_EX                                              2014
         28        DO_FCALL                                      0  $9      
         29        SEND_VAR                                                 $9
         30        DO_ICALL                                                 
   19    31        INIT_FCALL                                               'var_dump'
         32        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         33        FETCH_CONSTANT                                   ~11     'CAL_GREGORIAN'
         34        SEND_VAL_EX                                              ~11
         35        SEND_VAL_EX                                              10
         36        SEND_VAL_EX                                              2014
         37        DO_FCALL                                      0  $12     
         38        SEND_VAR                                                 $12
         39        DO_ICALL                                                 
   20    40        INIT_FCALL                                               'var_dump'
         41        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         42        FETCH_CONSTANT                                   ~14     'CAL_GREGORIAN'
         43        SEND_VAL_EX                                              ~14
         44        SEND_VAL_EX                                              11
         45        SEND_VAL_EX                                              2014
         46        DO_FCALL                                      0  $15     
         47        SEND_VAR                                                 $15
         48        DO_ICALL                                                 
   23    49        INIT_FCALL                                               'var_dump'
         50        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         51        FETCH_CONSTANT                                   ~17     'CAL_GREGORIAN'
         52        SEND_VAL_EX                                              ~17
         53        SEND_VAL_EX                                              2
         54        SEND_VAL_EX                                              1804
         55        DO_FCALL                                      0  $18     
         56        SEND_VAR                                                 $18
         57        DO_ICALL                                                 
   24    58        INIT_FCALL                                               'var_dump'
         59        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         60        FETCH_CONSTANT                                   ~20     'CAL_GREGORIAN'
         61        SEND_VAL_EX                                              ~20
         62        SEND_VAL_EX                                              2
         63        SEND_VAL_EX                                              2000
         64        DO_FCALL                                      0  $21     
         65        SEND_VAR                                                 $21
         66        DO_ICALL                                                 
   25    67        INIT_FCALL                                               'var_dump'
         68        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         69        FETCH_CONSTANT                                   ~23     'CAL_GREGORIAN'
         70        SEND_VAL_EX                                              ~23
         71        SEND_VAL_EX                                              2
         72        SEND_VAL_EX                                              2056
         73        DO_FCALL                                      0  $24     
         74        SEND_VAR                                                 $24
         75        DO_ICALL                                                 
   26    76        INIT_FCALL                                               'var_dump'
         77        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         78        FETCH_CONSTANT                                   ~26     'CAL_GREGORIAN'
         79        SEND_VAL_EX                                              ~26
         80        SEND_VAL_EX                                              2
         81        SEND_VAL_EX                                              1994
         82        DO_FCALL                                      0  $27     
         83        SEND_VAR                                                 $27
         84        DO_ICALL                                                 
   29    85        INIT_FCALL                                               'var_dump'
         86        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         87        FETCH_CONSTANT                                   ~29     'CAL_GREGORIAN'
         88        SEND_VAL_EX                                              ~29
         89        SEND_VAL_EX                                              1
         90        SEND_VAL_EX                                              1
         91        DO_FCALL                                      0  $30     
         92        SEND_VAR                                                 $30
         93        DO_ICALL                                                 
   30    94        INIT_FCALL                                               'var_dump'
         95        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
         96        FETCH_CONSTANT                                   ~32     'CAL_GREGORIAN'
         97        SEND_VAL_EX                                              ~32
         98        SEND_VAL_EX                                              14
         99        SEND_VAL_EX                                              2014
        100        DO_FCALL                                      0  $33     
        101        SEND_VAR                                                 $33
        102        DO_ICALL                                                 
   31   103        INIT_FCALL                                               'var_dump'
        104        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        105        FETCH_CONSTANT                                   ~35     'CAL_GREGORIAN'
        106        SEND_VAL_EX                                              ~35
        107        SEND_VAL_EX                                              1
        108        SEND_VAL_EX                                              2014000
        109        DO_FCALL                                      0  $36     
        110        SEND_VAR                                                 $36
        111        DO_ICALL                                                 
   32   112        INIT_FCALL                                               'var_dump'
        113        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        114        FETCH_CONSTANT                                   ~38     'CAL_GREGORIAN'
        115        SEND_VAL_EX                                              ~38
        116        SEND_VAL_EX                                              0
        117        SEND_VAL_EX                                              2014
        118        DO_FCALL                                      0  $39     
        119        SEND_VAR                                                 $39
        120        DO_ICALL                                                 
   33   121        INIT_FCALL                                               'var_dump'
        122        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        123        FETCH_CONSTANT                                   ~41     'CAL_GREGORIAN'
        124        SEND_VAL_EX                                              ~41
        125        SEND_VAL_EX                                              -1
        126        SEND_VAL_EX                                              2014
        127        DO_FCALL                                      0  $42     
        128        SEND_VAR                                                 $42
        129        DO_ICALL                                                 
   34   130        INIT_FCALL                                               'var_dump'
        131        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        132        FETCH_CONSTANT                                   ~44     'CAL_GREGORIAN'
        133        SEND_VAL_EX                                              ~44
        134        SEND_VAL_EX                                              1
        135        SEND_VAL_EX                                              0
        136        DO_FCALL                                      0  $45     
        137        SEND_VAR                                                 $45
        138        DO_ICALL                                                 
   35   139        INIT_FCALL                                               'var_dump'
        140        INIT_FCALL_BY_NAME                                       'cal_days_in_month'
        141        FETCH_CONSTANT                                   ~47     'CAL_GREGORIAN'
        142        SEND_VAL_EX                                              ~47
        143        SEND_VAL_EX                                              1
        144        SEND_VAL_EX                                              -1
        145        DO_FCALL                                      0  $48     
        146        SEND_VAR                                                 $48
        147        DO_ICALL                                                 
        148      > RETURN                                                   1

Function %00cal_days_in_month%2Fin%2Fek0oZ%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/ek0oZ
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%2Fek0oZ%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.55 ms | 1412 KiB | 19 Q