3v4l.org

run code in 300+ PHP versions simultaneously
<?php $difference = new DateTime(); $difference = $difference->diff(new DateTime('now + 2 years + 1 month + 2 weeks + 3 days + 40 seconds'), true); $periods = array( 'y' => 'year', 'm' => 'month', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second' ); foreach($periods as $attribute => $verb) { var_dump($difference->$attribute); if(isset($difference->$attribute) && $difference->$attribute !== 0) { die((string) $verb); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 24
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/iNuZ5
function name:  (null)
number of ops:  30
compiled vars:  !0 = $difference, !1 = $periods, !2 = $verb, !3 = $attribute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    4     3        INIT_METHOD_CALL                                         !0, 'diff'
          4        NEW                                              $7      'DateTime'
          5        SEND_VAL_EX                                              'now+%2B+2+years+%2B+1+month+%2B+2+weeks+%2B+3+days+%2B+40+seconds'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $7
          8        SEND_VAL_EX                                              <true>
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !0, $9
    6    11        ASSIGN                                                   !1, <array>
   15    12      > FE_RESET_R                                       $12     !1, ->28
         13    > > FE_FETCH_R                                       ~13     $12, !2, ->28
         14    >   ASSIGN                                                   !3, ~13
   16    15        INIT_FCALL                                               'var_dump'
         16        FETCH_OBJ_R                                      ~15     !0, !3
         17        SEND_VAL                                                 ~15
         18        DO_ICALL                                                 
   17    19        ISSET_ISEMPTY_PROP_OBJ                           ~17     !0, !3
         20      > JMPZ_EX                                          ~17     ~17, ->24
         21    >   FETCH_OBJ_R                                      ~18     !0, !3
         22        IS_NOT_IDENTICAL                                 ~19     ~18, 0
         23        BOOL                                             ~17     ~19
         24    > > JMPZ                                                     ~17, ->27
   18    25    >   CAST                                          6  ~20     !2
         26      > EXIT                                                     ~20
   15    27    > > JMP                                                      ->13
         28    >   FE_FREE                                                  $12
   20    29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.8 ms | 1388 KiB | 15 Q