3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getAge($dob) { $dob = strtotime($dob); $y = date('Y', $dob); if (($m = (date('m') - date('m', $dob))) < 0) { $y++; } elseif ($m == 0 && date('d') - date('d', $dob) < 0) { $y++; } return date('Y') - $y; } /*** a date before 1970 ***/ $dob = "April 20 1961"; /*** another date ***/ $tdate = "21-04-2009"; /*** show the date ***/ echo getAge( $dob, $tdate );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tOPWN
function name:  (null)
number of ops:  8
compiled vars:  !0 = $dob, !1 = $tdate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 'April+20+1961'
   22     1        ASSIGN                                                   !1, '21-04-2009'
   25     2        INIT_FCALL                                               'getage'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
          7      > RETURN                                                   1

Function getage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 35
filename:       /in/tOPWN
function name:  getAge
number of ops:  43
compiled vars:  !0 = $dob, !1 = $y, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strtotime'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
    6     5        INIT_FCALL                                               'date'
          6        SEND_VAL                                                 'Y'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
    8    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'm'
         12        DO_ICALL                                         $7      
         13        INIT_FCALL                                               'date'
         14        SEND_VAL                                                 'm'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $8      
         17        SUB                                              ~9      $7, $8
         18        ASSIGN                                           ~10     !2, ~9
         19        IS_SMALLER                                               ~10, 0
         20      > JMPZ                                                     ~11, ->23
    9    21    >   PRE_INC                                                  !1
         22      > JMP                                                      ->37
   10    23    >   IS_EQUAL                                         ~13     !2, 0
         24      > JMPZ_EX                                          ~13     ~13, ->35
         25    >   INIT_FCALL                                               'date'
         26        SEND_VAL                                                 'd'
         27        DO_ICALL                                         $14     
         28        INIT_FCALL                                               'date'
         29        SEND_VAL                                                 'd'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $15     
         32        SUB                                              ~16     $14, $15
         33        IS_SMALLER                                       ~17     ~16, 0
         34        BOOL                                             ~13     ~17
         35    > > JMPZ                                                     ~13, ->37
   11    36    >   PRE_INC                                                  !1
   14    37    >   INIT_FCALL                                               'date'
         38        SEND_VAL                                                 'Y'
         39        DO_ICALL                                         $19     
         40        SUB                                              ~20     $19, !1
         41      > RETURN                                                   ~20
   16    42*     > RETURN                                                   null

End of function getage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.33 ms | 1403 KiB | 18 Q