3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Routes { static $routes = array(); static function add($route, $controller, $action) { //self::routes = '1';//;array($route, $controller.'Controller', $action); } static function getRoutes() { return self::$routes; } } /* class BooksController { static function index() { $books = BookModel::all() } static function show() { $id = 1; $books = BookModel::find(1); } } class BookModel { static function all() { $books = array('Book', 'Book', 'Book'); return $books; } static function find() { $book = 'Book'; return $books; } } class View { } */ Routes::add('/books', 'Books', 'index'); Routes::add('/books/:id', 'Books', 'show'); print_r(Routes::getRoutes());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kr2Wv
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   INIT_STATIC_METHOD_CALL                                  'Routes', 'add'
          1        SEND_VAL                                                 '%2Fbooks'
          2        SEND_VAL                                                 'Books'
          3        SEND_VAL                                                 'index'
          4        DO_FCALL                                      0          
   57     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          
   59    10        INIT_FCALL                                               'print_r'
         11        INIT_STATIC_METHOD_CALL                                  'Routes', 'getRoutes'
         12        DO_FCALL                                      0  $2      
         13        SEND_VAR                                                 $2
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class Routes:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kr2Wv
function name:  add
number of ops:  4
compiled vars:  !0 = $route, !1 = $controller, !2 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3      > 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/kr2Wv
function name:  getRoutes
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'routes'
          1      > RETURN                                                   ~0
   15     2*     > RETURN                                                   null

End of function getroutes

End of class Routes.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.31 ms | 1396 KiB | 15 Q