3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Application\Router; use Application\Views as Views; class Router { private $request_uri; private $routes = array(); public function __construct($request_uri) { $this->request_uri = $request_uri; /** * Routes go here. * The URI is matched against the routes IN THE ORDER THEY ARE DEFINED! */ $this->addRoute('/\/?events\/?/'); $this->addRoute('/^\/$/'); } public function addRoute($regex) { $this->routes[] = $regex; } public function route() { $match = FALSE; for ($x = 0; $x < count($this->routes); $x ++) { if (preg_match($this->routes[$x], $this->request_uri)) { $match = TRUE; } } if ($match === FALSE) { new Views\FOF(); } else { $v = new Views\Events(); echo $v->blah; } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FZKcU
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E > > RETURN                                                   1

Class Application\Router\Router:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FZKcU
function name:  __construct
number of ops:  10
compiled vars:  !0 = $request_uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'request_uri'
          2        OP_DATA                                                  !0
   21     3        INIT_METHOD_CALL                                         'addRoute'
          4        SEND_VAL_EX                                              '%2F%5C%2F%3Fevents%5C%2F%3F%2F'
          5        DO_FCALL                                      0          
   22     6        INIT_METHOD_CALL                                         'addRoute'
          7        SEND_VAL_EX                                              '%2F%5E%5C%2F%24%2F'
          8        DO_FCALL                                      0          
   23     9      > RETURN                                                   null

End of function __construct

Function addroute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FZKcU
function name:  addRoute
number of ops:  5
compiled vars:  !0 = $regex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        FETCH_OBJ_W                                      $1      'routes'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   28     4      > RETURN                                                   null

End of function addroute

Function route:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 3
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 3
Branch analysis from position: 22
Branch analysis from position: 3
Branch analysis from position: 14
filename:       /in/FZKcU
function name:  route
number of ops:  34
compiled vars:  !0 = $match, !1 = $x, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, <false>
   34     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->15
   35     3    >   INIT_NS_FCALL_BY_NAME                                    'Application%5CRouter%5Cpreg_match'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $5      'routes'
          6        FETCH_DIM_FUNC_ARG                               $6      $5, !1
          7        SEND_FUNC_ARG                                            $6
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $7      'request_uri'
         10        SEND_FUNC_ARG                                            $7
         11        DO_FCALL                                      0  $8      
         12      > JMPZ                                                     $8, ->14
   36    13    >   ASSIGN                                                   !0, <true>
   34    14    >   PRE_INC                                                  !1
         15    >   INIT_NS_FCALL_BY_NAME                                    'Application%5CRouter%5Ccount'
         16        CHECK_FUNC_ARG                                           
         17        FETCH_OBJ_FUNC_ARG                               $11     'routes'
         18        SEND_FUNC_ARG                                            $11
         19        DO_FCALL                                      0  $12     
         20        IS_SMALLER                                               !1, $12
         21      > JMPNZ                                                    ~13, ->3
   40    22    >   TYPE_CHECK                                    4          !0
         23      > JMPZ                                                     ~14, ->28
   41    24    >   NEW                                              $15     'Application%5CViews%5CFOF'
         25        DO_FCALL                                      0          
         26        FREE                                                     $15
         27      > JMP                                                      ->33
   43    28    >   NEW                                              $17     'Application%5CViews%5CEvents'
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !2, $17
   44    31        FETCH_OBJ_R                                      ~20     !2, 'blah'
         32        ECHO                                                     ~20
   46    33    > > RETURN                                                   null

End of function route

End of class Application\Router\Router.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.42 ms | 1400 KiB | 17 Q