3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CallableStringifier { private static $callables = array(); public static function stringify($callable) { $id = count(self::$callables); self::$callables[$id] = $callable; return 'return ' . __CLASS__ . "::call($id, func_get_args());"; } public static function call($id, $args) { return call_user_func_array(self::$callables[$id], $args); } } $func = create_function('$arg1', CallableStringifier::stringify(function($arg1) { return $arg1; })); echo $func("echo $con;"); // outputs 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/23V2B
function name:  (null)
number of ops:  17
compiled vars:  !0 = $func, !1 = $con
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL_BY_NAME                                       'create_function'
          1        SEND_VAL_EX                                              '%24arg1'
          2        INIT_STATIC_METHOD_CALL                                  'CallableStringifier', 'stringify'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F23V2B%3A20%240'
   22     4        SEND_VAL                                                 ~2
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR_NO_REF_EX                                       $3
          7        DO_FCALL                                      0  $4      
   20     8        ASSIGN                                                   !0, $4
   24     9        INIT_DYNAMIC_CALL                                        !0
         10        ROPE_INIT                                     3  ~7      'echo+'
         11        ROPE_ADD                                      1  ~7      ~7, !1
         12        ROPE_END                                      2  ~6      ~7, '%3B'
         13        SEND_VAL_EX                                              ~6
         14        DO_FCALL                                      0  $9      
         15        ECHO                                                     $9
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F23V2B%3A20%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/23V2B
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $arg1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1      > RETURN                                                   !0
   22     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F23V2B%3A20%240

Class CallableStringifier:
Function stringify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/23V2B
function name:  stringify
number of ops:  13
compiled vars:  !0 = $callable, !1 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        FETCH_STATIC_PROP_R          unknown             ~2      'callables'
          2        COUNT                                            ~3      ~2
          3        ASSIGN                                                   !1, ~3
   10     4        FETCH_STATIC_PROP_W          unknown             $5      'callables'
          5        ASSIGN_DIM                                               $5, !1
          6        OP_DATA                                                  !0
   11     7        ROPE_INIT                                     3  ~8      '%3A%3Acall%28'
          8        ROPE_ADD                                      1  ~8      ~8, !1
          9        ROPE_END                                      2  ~7      ~8, '%2C+func_get_args%28%29%29%3B'
         10        CONCAT                                           ~10     'return+CallableStringifier', ~7
         11      > RETURN                                                   ~10
   12    12*     > RETURN                                                   null

End of function stringify

Function call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/23V2B
function name:  call
number of ops:  10
compiled vars:  !0 = $id, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        FETCH_STATIC_PROP_R          unknown             ~2      'callables'
          3        FETCH_DIM_R                                      ~3      ~2, !0
          4        INIT_USER_CALL                                0          'call_user_func_array', ~3
          5        SEND_ARRAY                                               !1
          6        CHECK_UNDEF_ARGS                                         
          7        DO_FCALL                                      0  $4      
          8      > RETURN                                                   $4
   17     9*     > RETURN                                                   null

End of function call

End of class CallableStringifier.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.78 ms | 1390 KiB | 16 Q