3v4l.org

run code in 500+ PHP versions simultaneously
<?php function diffInMonth(DateTime $start,DateTime $end): int { list($yearStart,$monthStart,$dayStart) = explode(" ",$start->format("Y m dHis")); list($yearEnd,$monthEnd, $dayEnd) = explode(" ",$end->format("Y m dHis")); $mothDiff = ($yearEnd - $yearStart) * 12 + $monthEnd - $monthStart; if($dayStart > $dayEnd) --$mothDiff; return $mothDiff; } $startDate = new DateTime('2022-11-01 00:00:00.0', new DateTimeZone('Africa/Nairobi')); $endDate = new DateTime('2022-12-01 00:00:00.0', new DateTimeZone('Africa/Nairobi')); $month = diffInMonth($startDate, $endDate); echo $month;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SmtQJ
function name:  (null)
number of ops:  23
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $month
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   NEW                                                  $3      'DateTime'
          1        SEND_VAL_EX                                                  '2022-11-01+00%3A00%3A00.0'
          2        NEW                                                  $4      'DateTimeZone'
          3        SEND_VAL_EX                                                  'Africa%2FNairobi'
          4        DO_FCALL                                          0          
          5        SEND_VAR_NO_REF_EX                                           $4
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !0, $3
   12     8        NEW                                                  $8      'DateTime'
          9        SEND_VAL_EX                                                  '2022-12-01+00%3A00%3A00.0'
         10        NEW                                                  $9      'DateTimeZone'
         11        SEND_VAL_EX                                                  'Africa%2FNairobi'
         12        DO_FCALL                                          0          
         13        SEND_VAR_NO_REF_EX                                           $9
         14        DO_FCALL                                          0          
         15        ASSIGN                                                       !1, $8
   14    16        INIT_FCALL                                                   'diffinmonth'
         17        SEND_VAR                                                     !0
         18        SEND_VAR                                                     !1
         19        DO_FCALL                                          0  $13     
         20        ASSIGN                                                       !2, $13
   15    21        ECHO                                                         !2
   16    22      > RETURN                                                       1

Function diffinmonth:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/SmtQJ
function name:  diffInMonth
number of ops:  42
compiled vars:  !0 = $start, !1 = $end, !2 = $yearStart, !3 = $monthStart, !4 = $dayStart, !5 = $yearEnd, !6 = $monthEnd, !7 = $dayEnd, !8 = $mothDiff
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    4     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '+'
          4        INIT_METHOD_CALL                                             !0, 'format'
          5        SEND_VAL_EX                                                  'Y+m+dHis'
          6        DO_FCALL                                          0  $9      
          7        SEND_VAR                                                     $9
          8        DO_ICALL                                             $10     
          9        FETCH_LIST_R                                         $11     $10, 0
         10        ASSIGN                                                       !2, $11
         11        FETCH_LIST_R                                         $13     $10, 1
         12        ASSIGN                                                       !3, $13
         13        FETCH_LIST_R                                         $15     $10, 2
         14        ASSIGN                                                       !4, $15
         15        FREE                                                         $10
    5    16        INIT_FCALL                                                   'explode'
         17        SEND_VAL                                                     '+'
         18        INIT_METHOD_CALL                                             !1, 'format'
         19        SEND_VAL_EX                                                  'Y+m+dHis'
         20        DO_FCALL                                          0  $17     
         21        SEND_VAR                                                     $17
         22        DO_ICALL                                             $18     
         23        FETCH_LIST_R                                         $19     $18, 0
         24        ASSIGN                                                       !5, $19
         25        FETCH_LIST_R                                         $21     $18, 1
         26        ASSIGN                                                       !6, $21
         27        FETCH_LIST_R                                         $23     $18, 2
         28        ASSIGN                                                       !7, $23
         29        FREE                                                         $18
    6    30        SUB                                                  ~25     !5, !2
         31        MUL                                                  ~26     ~25, 12
         32        ADD                                                  ~27     ~26, !6
         33        SUB                                                  ~28     ~27, !3
         34        ASSIGN                                                       !8, ~28
    7    35        IS_SMALLER                                                   !7, !4
         36      > JMPZ                                                         ~30, ->38
         37    >   PRE_DEC                                                      !8
    8    38    >   VERIFY_RETURN_TYPE                                           !8
         39      > RETURN                                                       !8
    9    40*       VERIFY_RETURN_TYPE                                           
         41*     > RETURN                                                       null

End of function diffinmonth

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
150.36 ms | 1882 KiB | 15 Q