3v4l.org

run code in 300+ PHP versions simultaneously
<?php // todays date $today = date("Ymd"); $birth_date = '1981-02-09'; //Call the age function $age = getAge($birth_date); echo PHP_EOL . $age; function getAge($birth_date){ list($year, $month, $day) = explode("-", $birth_date); var_dump($year, $month, $day); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; echo $day_diff . PHP_EOL; if ($day_diff < 0 || $month_diff < 0) $year_diff--; return $year_diff; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1nP42
function name:  (null)
number of ops:  12
compiled vars:  !0 = $today, !1 = $birth_date, !2 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Ymd'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
    6     4        ASSIGN                                                   !1, '1981-02-09'
    8     5        INIT_FCALL_BY_NAME                                       'getAge'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   10     9        CONCAT                                           ~8      '%0A', !2
         10        ECHO                                                     ~8
   22    11      > RETURN                                                   1

Function getage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 38
filename:       /in/1nP42
function name:  getAge
number of ops:  42
compiled vars:  !0 = $birth_date, !1 = $year, !2 = $month, !3 = $day, !4 = $year_diff, !5 = $month_diff, !6 = $day_diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        FETCH_LIST_R                                     $8      $7, 0
          6        ASSIGN                                                   !1, $8
          7        FETCH_LIST_R                                     $10     $7, 1
          8        ASSIGN                                                   !2, $10
          9        FETCH_LIST_R                                     $12     $7, 2
         10        ASSIGN                                                   !3, $12
         11        FREE                                                     $7
   14    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                                 
   15    17        INIT_FCALL                                               'date'
         18        SEND_VAL                                                 'Y'
         19        DO_ICALL                                         $15     
         20        SUB                                              ~16     $15, !1
         21        ASSIGN                                                   !4, ~16
   16    22        INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'm'
         24        DO_ICALL                                         $18     
         25        SUB                                              ~19     $18, !2
         26        ASSIGN                                                   !5, ~19
   17    27        INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'd'
         29        DO_ICALL                                         $21     
         30        SUB                                              ~22     $21, !3
         31        ASSIGN                                                   !6, ~22
   18    32        CONCAT                                           ~24     !6, '%0A'
         33        ECHO                                                     ~24
   19    34        IS_SMALLER                                       ~25     !6, 0
         35      > JMPNZ_EX                                         ~25     ~25, ->38
         36    >   IS_SMALLER                                       ~26     !5, 0
         37        BOOL                                             ~25     ~26
         38    > > JMPZ                                                     ~25, ->40
   20    39    >   PRE_DEC                                                  !4
   21    40    > > RETURN                                                   !4
   22    41*     > RETURN                                                   null

End of function getage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.65 ms | 1400 KiB | 19 Q