3v4l.org

run code in 300+ PHP versions simultaneously
<?php function memoize($func) { return function () use ($func) { static $cache = []; $args = func_get_args(); $key = md5(serialize($args)); if ( !isset($cache[$key]) ) { $cache[$key] = call_user_func_array($func, $args); } return $cache[$key]; }; }; $cube = function($number) { return $number * $number * $number; }; $cube3 = memoize($cube, 3); echo $cube3();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QXTZP
function name:  (null)
number of ops:  11
compiled vars:  !0 = $cube, !1 = $cube3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQXTZP%3A18%241'
          1        ASSIGN                                                   !0, ~2
   22     2        INIT_FCALL                                               'memoize'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 3
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   24     7        INIT_DYNAMIC_CALL                                        !1
          8        DO_FCALL                                      0  $6      
          9        ECHO                                                     $6
         10      > RETURN                                                   1

Function memoize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QXTZP
function name:  memoize
number of ops:  5
compiled vars:  !0 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQXTZP%3A3%240'
          2        BIND_LEXICAL                                             ~1, !0
   14     3      > RETURN                                                   ~1
   15     4*     > RETURN                                                   null

End of function memoize

Function %00%7Bclosure%7D%2Fin%2FQXTZP%3A3%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/QXTZP
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $func, !1 = $cache, !2 = $args, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   BIND_STATIC                                              !0
    4     1        BIND_STATIC                                              !1
    6     2        FUNC_GET_ARGS                                    ~4      
          3        ASSIGN                                                   !2, ~4
    7     4        INIT_FCALL                                               'md5'
          5        INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !3, $7
    9    11        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !1, !3
         12        BOOL_NOT                                         ~10     ~9
         13      > JMPZ                                                     ~10, ->20
   10    14    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         15        SEND_ARRAY                                               !2
         16        CHECK_UNDEF_ARGS                                         
         17        DO_FCALL                                      0  $12     
         18        ASSIGN_DIM                                               !1, !3
         19        OP_DATA                                                  $12
   13    20    >   FETCH_DIM_R                                      ~13     !1, !3
         21      > RETURN                                                   ~13
   14    22*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FQXTZP%3A3%240

Function %00%7Bclosure%7D%2Fin%2FQXTZP%3A18%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QXTZP
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        MUL                                              ~1      !0, !0
          2        MUL                                              ~2      !0, ~1
          3      > RETURN                                                   ~2
   20     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FQXTZP%3A18%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.8 ms | 1403 KiB | 18 Q