3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MVCFramework { var $url = ''; function __construct($url) { $this->url = $url; //HTTP_REQUEST URL $this->run(); } function run() { if ($route = Routes::getRoute($this->url)) { list($controller, $action) = $route; $controllerObj = new $controller; $controllerObj->$action(); print_r(get_object_vars($controllerObj)); //template } else { print_r('404'); } } } class Routes { static $routes = array(); static function add($route, $controller, $action) { self::$routes[$route] = array($controller.'Controller', $action); } static function getRoutes() { return self::$routes; } static function getRoute($url) { return self::$routes[$url]; } } abstract class Model { // connect to DB and etc. } // controllers/BookController.php class BooksController { function index() { $this->books = Book::all(); } function show() { $id = 1; $this->book = Book::find(1); } } // models/Book.php class Book { static function all() { $books = array('Book', 'Book', 'Book'); return $books; } static function find() { $book = 'Book'; return $book; } } Routes::add('/books', 'Books', 'index'); Routes::add('/books/:id', 'Books', 'show'); $url = '/books'; new MVCFramework($url);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  (null)
number of ops:  16
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   90     0  E >   INIT_STATIC_METHOD_CALL                                  'Routes', 'add'
          1        SEND_VAL                                                 '%2Fbooks'
          2        SEND_VAL                                                 'Books'
          3        SEND_VAL                                                 'index'
          4        DO_FCALL                                      0          
   91     5        INIT_STATIC_METHOD_CALL                                  'Routes', 'add'
          6        SEND_VAL                                                 '%2Fbooks%2F%3Aid'
          7        SEND_VAL                                                 'Books'
          8        SEND_VAL                                                 'show'
          9        DO_FCALL                                      0          
   94    10        ASSIGN                                                   !0, '%2Fbooks'
   96    11        NEW                                              $4      'MVCFramework'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
         14        FREE                                                     $4
         15      > RETURN                                                   1

Class MVCFramework:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  __construct
number of ops:  6
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'url'
          2        OP_DATA                                                  !0
   10     3        INIT_METHOD_CALL                                         'run'
          4        DO_FCALL                                      0          
   11     5      > RETURN                                                   null

End of function __construct

Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  run
number of ops:  30
compiled vars:  !0 = $route, !1 = $controller, !2 = $action, !3 = $controllerObj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'Routes', 'getRoute'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $4      'url'
          3        SEND_FUNC_ARG                                            $4
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                           ~6      !0, $5
          6      > JMPZ                                                     ~6, ->26
   16     7    >   QM_ASSIGN                                        ~7      !0
          8        FETCH_LIST_R                                     $8      ~7, 0
          9        ASSIGN                                                   !1, $8
         10        FETCH_LIST_R                                     $10     ~7, 1
         11        ASSIGN                                                   !2, $10
         12        FREE                                                     ~7
   18    13        FETCH_CLASS                                   0  $12     !1
         14        NEW                                              $13     $12
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !3, $13
   19    17        INIT_METHOD_CALL                                         !3, !2
         18        DO_FCALL                                      0          
   21    19        INIT_FCALL                                               'print_r'
         20        INIT_FCALL                                               'get_object_vars'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $17     
         23        SEND_VAR                                                 $17
         24        DO_ICALL                                                 
         25      > JMP                                                      ->29
   24    26    >   INIT_FCALL                                               'print_r'
         27        SEND_VAL                                                 '404'
         28        DO_ICALL                                                 
   26    29    > > RETURN                                                   null

End of function run

End of class MVCFramework.

Class Routes:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  add
number of ops:  10
compiled vars:  !0 = $route, !1 = $controller, !2 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   35     3        CONCAT                                           ~5      !1, 'Controller'
          4        INIT_ARRAY                                       ~6      ~5
          5        ADD_ARRAY_ELEMENT                                ~6      !2
          6        FETCH_STATIC_PROP_W          global              $3      'routes'
          7        ASSIGN_DIM                                               $3, !0
          8        OP_DATA                                                  ~6
   36     9      > RETURN                                                   null

End of function add

Function getroutes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  getRoutes
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'routes'
          1      > RETURN                                                   ~0
   41     2*     > RETURN                                                   null

End of function getroutes

Function getroute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  getRoute
number of ops:  5
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   45     1        FETCH_STATIC_PROP_R          unknown             ~1      'routes'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   46     4*     > RETURN                                                   null

End of function getroute

End of class Routes.

Class Model: [no user functions]
Class BooksController:
Function index:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  index
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   INIT_STATIC_METHOD_CALL                                  'Book', 'all'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN_OBJ                                               'books'
          3        OP_DATA                                                  $1
   61     4      > RETURN                                                   null

End of function index

Function show:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  show
number of ops:  7
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   ASSIGN                                                   !0, 1
   66     1        INIT_STATIC_METHOD_CALL                                  'Book', 'find'
          2        SEND_VAL_EX                                              1
          3        DO_FCALL                                      0  $3      
          4        ASSIGN_OBJ                                               'book'
          5        OP_DATA                                                  $3
   67     6      > RETURN                                                   null

End of function show

End of class BooksController.

Class Book:
Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  all
number of ops:  3
compiled vars:  !0 = $books
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   ASSIGN                                                   !0, <array>
   78     1      > RETURN                                                   !0
   79     2*     > RETURN                                                   null

End of function all

Function find:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuavG
function name:  find
number of ops:  3
compiled vars:  !0 = $book
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   83     0  E >   ASSIGN                                                   !0, 'Book'
   84     1      > RETURN                                                   !0
   85     2*     > RETURN                                                   null

End of function find

End of class Book.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.54 ms | 1396 KiB | 17 Q