3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sDate = "2018-09-10 12:00:00"; $eDate = "2019-11-10 12:00:00"; $startDate = new DateTime($sDate); $diff = $startDate->diff(new DateTime($eDate)); if ($diff->y > 0) $diffStr = $diff->y." year"; else if ($diff->m > 0) $diffStr = $diff->m." month"; else if ($diff->d > 0) $diffStr = $diff->d." day"; else if ($diff->h > 0) $diffStr = $diff->h." hour"; else if ($diff->i > 0) $diffStr = $diff->i." minute"; else if ($diff->s > 0) $diffStr = $diff->i." second"; else $diffStr = "dates are same"; echo $diffStr;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 48
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EbZsO
function name:  (null)
number of ops:  58
compiled vars:  !0 = $sDate, !1 = $eDate, !2 = $startDate, !3 = $diff, !4 = $diffStr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '2018-09-10+12%3A00%3A00'
    3     1        ASSIGN                                                   !1, '2019-11-10+12%3A00%3A00'
    5     2        NEW                                              $7      'DateTime'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $7
    6     6        INIT_METHOD_CALL                                         !2, 'diff'
          7        NEW                                              $10     'DateTime'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $10
         11        DO_FCALL                                      0  $12     
         12        ASSIGN                                                   !3, $12
    8    13        FETCH_OBJ_R                                      ~14     !3, 'y'
         14        IS_SMALLER                                               0, ~14
         15      > JMPZ                                                     ~15, ->20
    9    16    >   FETCH_OBJ_R                                      ~16     !3, 'y'
         17        CONCAT                                           ~17     ~16, '+year'
         18        ASSIGN                                                   !4, ~17
    8    19      > JMP                                                      ->56
   10    20    >   FETCH_OBJ_R                                      ~19     !3, 'm'
         21        IS_SMALLER                                               0, ~19
         22      > JMPZ                                                     ~20, ->27
   11    23    >   FETCH_OBJ_R                                      ~21     !3, 'm'
         24        CONCAT                                           ~22     ~21, '+month'
         25        ASSIGN                                                   !4, ~22
   10    26      > JMP                                                      ->56
   12    27    >   FETCH_OBJ_R                                      ~24     !3, 'd'
         28        IS_SMALLER                                               0, ~24
         29      > JMPZ                                                     ~25, ->34
   13    30    >   FETCH_OBJ_R                                      ~26     !3, 'd'
         31        CONCAT                                           ~27     ~26, '+day'
         32        ASSIGN                                                   !4, ~27
   12    33      > JMP                                                      ->56
   14    34    >   FETCH_OBJ_R                                      ~29     !3, 'h'
         35        IS_SMALLER                                               0, ~29
         36      > JMPZ                                                     ~30, ->41
   15    37    >   FETCH_OBJ_R                                      ~31     !3, 'h'
         38        CONCAT                                           ~32     ~31, '+hour'
         39        ASSIGN                                                   !4, ~32
   14    40      > JMP                                                      ->56
   16    41    >   FETCH_OBJ_R                                      ~34     !3, 'i'
         42        IS_SMALLER                                               0, ~34
         43      > JMPZ                                                     ~35, ->48
   17    44    >   FETCH_OBJ_R                                      ~36     !3, 'i'
         45        CONCAT                                           ~37     ~36, '+minute'
         46        ASSIGN                                                   !4, ~37
   16    47      > JMP                                                      ->56
   18    48    >   FETCH_OBJ_R                                      ~39     !3, 's'
         49        IS_SMALLER                                               0, ~39
         50      > JMPZ                                                     ~40, ->55
   19    51    >   FETCH_OBJ_R                                      ~41     !3, 'i'
         52        CONCAT                                           ~42     ~41, '+second'
         53        ASSIGN                                                   !4, ~42
   18    54      > JMP                                                      ->56
   21    55    >   ASSIGN                                                   !4, 'dates+are+same'
   23    56    >   ECHO                                                     !4
   24    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.6 ms | 1002 KiB | 13 Q