3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo diffMonth("202407", "202408"); function diffMonth($month_A, $month_B) { // Extract year and month components $year_A = intval(substr($month_A, 0, 4)); $month_A = intval(substr($month_A, 4, 2)); $year_B = intval(substr($month_B, 0, 4)); $month_B = intval(substr($month_B, 4, 2)); // Calculate month difference $difference = ($year_A - $year_B) * 12 + ($month_A - $month_B); // Ensure positive difference return $difference; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TReBn
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL_BY_NAME                                       'diffMonth'
          1        SEND_VAL_EX                                              '202407'
          2        SEND_VAL_EX                                              '202408'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   16     5      > RETURN                                                   1

Function diffmonth:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TReBn
function name:  diffMonth
number of ops:  37
compiled vars:  !0 = $month_A, !1 = $month_B, !2 = $year_A, !3 = $year_B, !4 = $difference
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 4
          6        DO_ICALL                                         $5      
          7        CAST                                          4  ~6      $5
          8        ASSIGN                                                   !2, ~6
    7     9        INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 4
         12        SEND_VAL                                                 2
         13        DO_ICALL                                         $8      
         14        CAST                                          4  ~9      $8
         15        ASSIGN                                                   !0, ~9
    8    16        INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 0
         19        SEND_VAL                                                 4
         20        DO_ICALL                                         $11     
         21        CAST                                          4  ~12     $11
         22        ASSIGN                                                   !3, ~12
    9    23        INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !1
         25        SEND_VAL                                                 4
         26        SEND_VAL                                                 2
         27        DO_ICALL                                         $14     
         28        CAST                                          4  ~15     $14
         29        ASSIGN                                                   !1, ~15
   12    30        SUB                                              ~17     !2, !3
         31        MUL                                              ~18     ~17, 12
         32        SUB                                              ~19     !0, !1
         33        ADD                                              ~20     ~18, ~19
         34        ASSIGN                                                   !4, ~20
   15    35      > RETURN                                                   !4
   16    36*     > RETURN                                                   null

End of function diffmonth

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.81 ms | 1015 KiB | 14 Q