3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dob = new DateTime('24 June 1940'); $now = new DateTime('now'); echo year_diff($now, $dob); function year_diff($date1, $date2) { list($year1, $dayOfYear1) = explode(' ', $date1->format('Y z')); list($year2, $dayOfYear2) = explode(' ', $date2->format('Y z')); return $year1 - $year2 - ($dayOfYear1 < $dayOfYear2); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UFo9g
function name:  (null)
number of ops:  14
compiled vars:  !0 = $dob, !1 = $now
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'DateTime'
          1        SEND_VAL_EX                                              '24+June+1940'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
    4     4        NEW                                              $5      'DateTime'
          5        SEND_VAL_EX                                              'now'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
    6     8        INIT_FCALL_BY_NAME                                       'year_diff'
          9        SEND_VAR_EX                                              !1
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $8      
         12        ECHO                                                     $8
   12    13      > RETURN                                                   1

Function year_diff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UFo9g
function name:  year_diff
number of ops:  31
compiled vars:  !0 = $date1, !1 = $date2, !2 = $year1, !3 = $dayOfYear1, !4 = $year2, !5 = $dayOfYear2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+'
          4        INIT_METHOD_CALL                                         !0, 'format'
          5        SEND_VAL_EX                                              'Y+z'
          6        DO_FCALL                                      0  $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9        FETCH_LIST_R                                     $8      $7, 0
         10        ASSIGN                                                   !2, $8
         11        FETCH_LIST_R                                     $10     $7, 1
         12        ASSIGN                                                   !3, $10
         13        FREE                                                     $7
   10    14        INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '+'
         16        INIT_METHOD_CALL                                         !1, 'format'
         17        SEND_VAL_EX                                              'Y+z'
         18        DO_FCALL                                      0  $12     
         19        SEND_VAR                                                 $12
         20        DO_ICALL                                         $13     
         21        FETCH_LIST_R                                     $14     $13, 0
         22        ASSIGN                                                   !4, $14
         23        FETCH_LIST_R                                     $16     $13, 1
         24        ASSIGN                                                   !5, $16
         25        FREE                                                     $13
   11    26        SUB                                              ~18     !2, !4
         27        IS_SMALLER                                       ~19     !3, !5
         28        SUB                                              ~20     ~18, ~19
         29      > RETURN                                                   ~20
   12    30*     > RETURN                                                   null

End of function year_diff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.45 ms | 945 KiB | 16 Q