3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Model { public $string; public function __construct() { $this->string = 'MVC + PHP = Awesome!'; } } class View { private $model; private $controller; public function __construct($controller,$model) { $this->controller = $controller; $this->model = $model; } public function output() { return '<p><a href="?action=clicked"'.$this->model->string.'</a></p>'; } } class Controller { private $model; public function __construct($model){ $this->model = $model; } public function clicked() { $this->model->string = 'Updated String!'; } } $model = new Model(); $controller = new Controller($model); $view = new View($controller, $model); if(isset($_GET['action']) && !empty($_GET['action'])) { $controller->{$_GET['action']}(); } echo $view->output(); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 19
filename:       /in/3lvWL
function name:  (null)
number of ops:  28
compiled vars:  !0 = $model, !1 = $controller, !2 = $view
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $3      'Model'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   38     3        NEW                                              $6      'Controller'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   39     7        NEW                                              $9      'View'
          8        SEND_VAR_EX                                              !1
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $9
   41    12        FETCH_IS                                         ~12     '_GET'
         13        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     ~12, 'action'
         14      > JMPZ_EX                                          ~13     ~13, ->19
         15    >   FETCH_IS                                         ~14     '_GET'
         16        ISSET_ISEMPTY_DIM_OBJ                         1  ~15     ~14, 'action'
         17        BOOL_NOT                                         ~16     ~15
         18        BOOL                                             ~13     ~16
         19    > > JMPZ                                                     ~13, ->24
   42    20    >   FETCH_R                      global              ~17     '_GET'
         21        FETCH_DIM_R                                      ~18     ~17, 'action'
         22        INIT_METHOD_CALL                                         !1, ~18
         23        DO_FCALL                                      0          
   44    24    >   INIT_METHOD_CALL                                         !2, 'output'
         25        DO_FCALL                                      0  $20     
         26        ECHO                                                     $20
   46    27      > RETURN                                                   1

Class Model:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lvWL
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'string'
          1        OP_DATA                                                  'MVC+%2B+PHP+%3D+Awesome%21'
    8     2      > RETURN                                                   null

End of function __construct

End of class Model.

Class View:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lvWL
function name:  __construct
number of ops:  7
compiled vars:  !0 = $controller, !1 = $model
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        ASSIGN_OBJ                                               'controller'
          3        OP_DATA                                                  !0
   17     4        ASSIGN_OBJ                                               'model'
          5        OP_DATA                                                  !1
   18     6      > RETURN                                                   null

End of function __construct

Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lvWL
function name:  output
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~0      'model'
          1        FETCH_OBJ_R                                      ~1      ~0, 'string'
          2        CONCAT                                           ~2      '%3Cp%3E%3Ca+href%3D%22%3Faction%3Dclicked%22', ~1
          3        CONCAT                                           ~3      ~2, '%3C%2Fa%3E%3C%2Fp%3E'
          4      > RETURN                                                   ~3
   22     5*     > RETURN                                                   null

End of function output

End of class View.

Class Controller:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lvWL
function name:  __construct
number of ops:  4
compiled vars:  !0 = $model
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        ASSIGN_OBJ                                               'model'
          2        OP_DATA                                                  !0
   30     3      > RETURN                                                   null

End of function __construct

Function clicked:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lvWL
function name:  clicked
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   FETCH_OBJ_W                                      $0      'model'
          1        ASSIGN_OBJ                                               $0, 'string'
          2        OP_DATA                                                  'Updated+String%21'
   34     3      > RETURN                                                   null

End of function clicked

End of class Controller.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.68 ms | 1399 KiB | 13 Q