3v4l.org

run code in 300+ PHP versions simultaneously
<?php // todays date $today = date("Ymd"); $birth_date = '1981-02-12'; //Call the age function $age = getAge($birth_date); echo $age; function getAge($birth_date){ list($year, $month, $day) = explode("-", $birth_date); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; 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/WOl8Z
function name:  (null)
number of ops:  11
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-12'
    8     5        INIT_FCALL_BY_NAME                                       'getAge'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   10     9        ECHO                                                     !2
   20    10      > RETURN                                                   1

Function getage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 31
filename:       /in/WOl8Z
function name:  getAge
number of ops:  35
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                                               'date'
         13        SEND_VAL                                                 'Y'
         14        DO_ICALL                                         $14     
         15        SUB                                              ~15     $14, !1
         16        ASSIGN                                                   !4, ~15
   15    17        INIT_FCALL                                               'date'
         18        SEND_VAL                                                 'm'
         19        DO_ICALL                                         $17     
         20        SUB                                              ~18     $17, !2
         21        ASSIGN                                                   !5, ~18
   16    22        INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'd'
         24        DO_ICALL                                         $20     
         25        SUB                                              ~21     $20, !3
         26        ASSIGN                                                   !6, ~21
   17    27        IS_SMALLER                                       ~23     !6, 0
         28      > JMPNZ_EX                                         ~23     ~23, ->31
         29    >   IS_SMALLER                                       ~24     !5, 0
         30        BOOL                                             ~23     ~24
         31    > > JMPZ                                                     ~23, ->33
   18    32    >   PRE_DEC                                                  !4
   19    33    > > RETURN                                                   !4
   20    34*     > RETURN                                                   null

End of function getage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.68 ms | 1400 KiB | 17 Q