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_array($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/KBafI
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%2FKBafI%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%2FKBafI%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KBafI
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%2FKBafI%3A18%240

Class RenderEngine:
Function block:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KBafI
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/KBafI
function name:  draw
number of ops:  9
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        FETCH_OBJ_R                                      ~2      'blocks'
          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          
   12     8      > RETURN                                                   null

End of function draw

End of class RenderEngine.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.88 ms | 1399 KiB | 13 Q