3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("EVENT_YEAR",2000); function getInterval( $strDate ){ list( $year,,) = explode( '-', $strDate ); return ($year - EVENT_YEAR); } $strDate = '2017-05-05'; $interval = getInterval( $strDate ); try { $date = new DateTime( "$strDate -$interval years" ); } catch (Exception $e) { echo $e->getMessage(); exit(1); } if ( $date->format("Y-m-d") == '2000-05-05') { echo "\nThe interval is $interval years."; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Found catch point at position: 18
Branch analysis from position: 18
2 jumps found. (Code = 107) Position 1 = 19, Position 2 = -2
Branch analysis from position: 19
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/mPtVh
function name:  (null)
number of ops:  33
compiled vars:  !0 = $strDate, !1 = $interval, !2 = $date, !3 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'EVENT_YEAR'
          2        SEND_VAL                                                 2000
          3        DO_ICALL                                                 
   10     4        ASSIGN                                                   !0, '2017-05-05'
   12     5        INIT_FCALL                                               'getinterval'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !1, $6
   14     9        NEW                                              $8      'DateTime'
         10        ROPE_INIT                                     4  ~10     !0
         11        ROPE_ADD                                      1  ~10     ~10, '+-'
         12        ROPE_ADD                                      2  ~10     ~10, !1
         13        ROPE_END                                      3  ~9      ~10, '+years'
         14        SEND_VAL_EX                                              ~9
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $8
         17      > JMP                                                      ->23
   15    18  E > > CATCH                                       last         'Exception'
   16    19    >   INIT_METHOD_CALL                                         !3, 'getMessage'
         20        DO_FCALL                                      0  $14     
         21        ECHO                                                     $14
   17    22      > EXIT                                                     1
   19    23    >   INIT_METHOD_CALL                                         !2, 'format'
         24        SEND_VAL_EX                                              'Y-m-d'
         25        DO_FCALL                                      0  $15     
         26        IS_EQUAL                                                 $15, '2000-05-05'
         27      > JMPZ                                                     ~16, ->32
   20    28    >   ROPE_INIT                                     3  ~18     '%0AThe+interval+is+'
         29        ROPE_ADD                                      1  ~18     ~18, !1
         30        ROPE_END                                      2  ~17     ~18, '+years.'
         31        ECHO                                                     ~17
   21    32    > > RETURN                                                   1

Function getinterval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mPtVh
function name:  getInterval
number of ops:  12
compiled vars:  !0 = $strDate, !1 = $year
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        FETCH_LIST_R                                     $3      $2, 0
          6        ASSIGN                                                   !1, $3
          7        FREE                                                     $2
    7     8        FETCH_CONSTANT                                   ~5      'EVENT_YEAR'
          9        SUB                                              ~6      !1, ~5
         10      > RETURN                                                   ~6
    8    11*     > RETURN                                                   null

End of function getinterval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.04 ms | 1403 KiB | 18 Q