3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Template { private $dir = 'app/views/'; public function render($template, $data = [], $renderNow = true){ ob_start(); extract($data, EXTR_SKIP); require $this->dir.$template.'.html'; $ret = ob_get_clean(); if($renderNow){ echo $ret; } return $ret; } } //in controllers/someController.php class SomeController { public function list(){ $template = new Template(); $template->render('list'); } public function show($id){ $template = new Template(); $template->render('some',['id' => $id]); } } //in frontController //somehow you know you need 'someController' and action - 'show': $someController = new SomeController(); $someController->list(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TvScq
function name:  (null)
number of ops:  6
compiled vars:  !0 = $someController
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   NEW                                              $1      'SomeController'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   39     3        INIT_METHOD_CALL                                         !0, 'list'
          4        DO_FCALL                                      0          
   42     5      > RETURN                                                   1

Class Template:
Function render:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/TvScq
function name:  render
number of ops:  20
compiled vars:  !0 = $template, !1 = $data, !2 = $renderNow, !3 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      <true>
    7     3        INIT_FCALL                                               'ob_start'
          4        DO_ICALL                                                 
    8     5        INIT_FCALL                                               'extract'
          6        SEND_REF                                                 !1
          7        SEND_VAL                                                 1
          8        DO_ICALL                                                 
    9     9        FETCH_OBJ_R                                      ~6      'dir'
         10        CONCAT                                           ~7      ~6, !0
         11        CONCAT                                           ~8      ~7, '.html'
         12        INCLUDE_OR_EVAL                                          ~8, REQUIRE
   10    13        INIT_FCALL                                               'ob_get_clean'
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !3, $10
   11    16      > JMPZ                                                     !2, ->18
   12    17    >   ECHO                                                     !3
   14    18    > > RETURN                                                   !3
   15    19*     > RETURN                                                   null

End of function render

End of class Template.

Class SomeController:
Function list:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TvScq
function name:  list
number of ops:  7
compiled vars:  !0 = $template
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'Template'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   25     3        INIT_METHOD_CALL                                         !0, 'render'
          4        SEND_VAL_EX                                              'list'
          5        DO_FCALL                                      0          
   26     6      > RETURN                                                   null

End of function list

Function show:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TvScq
function name:  show
number of ops:  10
compiled vars:  !0 = $id, !1 = $template
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        NEW                                              $2      'Template'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   30     4        INIT_METHOD_CALL                                         !1, 'render'
          5        SEND_VAL_EX                                              'some'
          6        INIT_ARRAY                                       ~5      !0, 'id'
          7        SEND_VAL_EX                                              ~5
          8        DO_FCALL                                      0          
   31     9      > RETURN                                                   null

End of function show

End of class SomeController.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.91 ms | 1392 KiB | 19 Q