3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RenderEngine { private $blocks = []; public function block($name, $callback) { $this->blocks[$name] = $callback; } public function draw($name, array $args) { call_user_func_args($this->blocks[$name], $args); } } $t = new RenderEngine(); ?> <?php $t->block('article', function ($article) { ?> <?=$article;?> <?php }); ?> <?=$t->draw('article', ['hello']);?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kE8Y4
function name:  (null)
number of ops:  16
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'RenderEngine'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   17     3        ECHO                                                     '%0A'
   18     4        INIT_METHOD_CALL                                         !0, 'block'
          5        SEND_VAL_EX                                              'article'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FkE8Y4%3A18%240'
   20     7        SEND_VAL_EX                                              ~4
          8        DO_FCALL                                      0          
   21     9        ECHO                                                     '%0A'
   22    10        INIT_METHOD_CALL                                         !0, 'draw'
         11        SEND_VAL_EX                                              'article'
         12        SEND_VAL_EX                                              <array>
         13        DO_FCALL                                      0  $6      
         14        ECHO                                                     $6
         15      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FkE8Y4%3A18%240

Class RenderEngine:
Function block:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kE8Y4
function name:  block
number of ops:  6
compiled vars:  !0 = $name, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        FETCH_OBJ_W                                      $2      'blocks'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
    8     5      > RETURN                                                   null

End of function block

Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kE8Y4
function name:  draw
number of ops:  10
compiled vars:  !0 = $name, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        INIT_FCALL_BY_NAME                                       'call_user_func_args'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $2      'blocks'
          5        FETCH_DIM_FUNC_ARG                               $3      $2, !0
          6        SEND_FUNC_ARG                                            $3
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
   12     9      > RETURN                                                   null

End of function draw

End of class RenderEngine.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.87 ms | 1399 KiB | 13 Q