3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dateDiff($start, $end) { $start = strtotime($start); $end = strtotime($end); $diff = $end - $start; return round($diff / 86400); } $d1 = new DateTime('2010-01-30'); $d2 = new DateTime(date(Y-m-d)); $diff = $d2->diff($d1); echo $diff->y;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q6TlK
function name:  (null)
number of ops:  23
compiled vars:  !0 = $d1, !1 = $d2, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $3      'DateTime'
          1        SEND_VAL_EX                                              '2010-01-30'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   10     4        NEW                                              $6      'DateTime'
          5        INIT_FCALL                                               'date'
          6        FETCH_CONSTANT                                   ~7      'Y'
          7        FETCH_CONSTANT                                   ~8      'm'
          8        SUB                                              ~9      ~7, ~8
          9        FETCH_CONSTANT                                   ~10     'd'
         10        SUB                                              ~11     ~9, ~10
         11        SEND_VAL                                                 ~11
         12        DO_ICALL                                         $12     
         13        SEND_VAR_NO_REF_EX                                       $12
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !1, $6
   11    16        INIT_METHOD_CALL                                         !1, 'diff'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $15     
         19        ASSIGN                                                   !2, $15
   13    20        FETCH_OBJ_R                                      ~17     !2, 'y'
         21        ECHO                                                     ~17
         22      > RETURN                                                   1

Function datediff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q6TlK
function name:  dateDiff
number of ops:  18
compiled vars:  !0 = $start, !1 = $end, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'strtotime'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !0, $3
    4     6        INIT_FCALL                                               'strtotime'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
    5    10        SUB                                              ~7      !1, !0
         11        ASSIGN                                                   !2, ~7
    6    12        INIT_FCALL                                               'round'
         13        DIV                                              ~9      !2, 86400
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                         $10     
         16      > RETURN                                                   $10
    7    17*     > RETURN                                                   null

End of function datediff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.02 ms | 1400 KiB | 19 Q