3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getYearsBetween( \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ): int { $dateInterval = $startDate->diff($endDate, true); return $dateInterval->y; } $start = new \DateTimeImmutable('2000-11-01 09:29:22.907606', new \DateTimeZone('America/Chicago')); $end = new \DateTimeImmutable('2022-06-06 11:00:00.000000', new \DateTimeZone('America/New_York')); $result = getYearsBetween($start, $end); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nmPAj
function name:  (null)
number of ops:  25
compiled vars:  !0 = $start, !1 = $end, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $3      'DateTimeImmutable'
          1        SEND_VAL_EX                                              '2000-11-01+09%3A29%3A22.907606'
          2        NEW                                              $4      'DateTimeZone'
          3        SEND_VAL_EX                                              'America%2FChicago'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $4
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $3
   12     8        NEW                                              $8      'DateTimeImmutable'
          9        SEND_VAL_EX                                              '2022-06-06+11%3A00%3A00.000000'
         10        NEW                                              $9      'DateTimeZone'
         11        SEND_VAL_EX                                              'America%2FNew_York'
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $9
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !1, $8
   13    16        INIT_FCALL                                               'getyearsbetween'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !1
         19        DO_FCALL                                      0  $13     
         20        ASSIGN                                                   !2, $13
   14    21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function getyearsbetween:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nmPAj
function name:  getYearsBetween
number of ops:  12
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $dateInterval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_METHOD_CALL                                         !0, 'diff'
          3        SEND_VAR_EX                                              !1
          4        SEND_VAL_EX                                              <true>
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
    8     7        FETCH_OBJ_R                                      ~5      !2, 'y'
          8        VERIFY_RETURN_TYPE                                       ~5
          9      > RETURN                                                   ~5
    9    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function getyearsbetween

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.58 ms | 1399 KiB | 16 Q