3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Route { static function start() { $controller_name = 'Main'; $action_name = 'index'; $routes = explode('/', $_SERVER['REQUEST_URI']); if ( !empty($routes[1]) ) { $controller_name = $routes[1]; } if ( !empty($routes[2]) ) { $action_name = $routes[2]; } $model_name = 'Model_'.$controller_name; $controller_name = 'Controller_'.$controller_name; $action_name = 'action_'.$action_name; $model_file = strtolower($model_name).'.php'; $model_path = "application/models/".$model_file; if(file_exists($model_path)) { include "application/models/".$model_file; } $controller_file = strtolower($controller_name).'.php'; $controller_path = "application/controllers/".$controller_file; if(file_exists($controller_path)) { include "application/controllers/".$controller_file; } else { Route::ErrorPage404(); } $controller = new $controller_name; $action = $action_name; if(method_exists($controller, $action)) { $controller->$action(); } else { Route::ErrorPage404(); } } function ErrorPage404() { $host = 'http://'.$_SERVER['HTTP_HOST'].'/'; header('HTTP/1.1 404 Not Found'); header("Status: 404 Not Found"); header('Location:'.$host.'404'); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sAYpB
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E > > RETURN                                                   1

Class Route:
Function start:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 52
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 67
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 67
Branch analysis from position: 64
Branch analysis from position: 67
Branch analysis from position: 38
Branch analysis from position: 19
Branch analysis from position: 14
filename:       /in/sAYpB
function name:  start
number of ops:  70
compiled vars:  !0 = $controller_name, !1 = $action_name, !2 = $routes, !3 = $model_name, !4 = $model_file, !5 = $model_path, !6 = $controller_file, !7 = $controller_path, !8 = $controller, !9 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'Main'
    9     1        ASSIGN                                                   !1, 'index'
   11     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2F'
          4        FETCH_R                      global              ~12     '_SERVER'
          5        FETCH_DIM_R                                      ~13     ~12, 'REQUEST_URI'
          6        SEND_VAL                                                 ~13
          7        DO_ICALL                                         $14     
          8        ASSIGN                                                   !2, $14
   14     9        ISSET_ISEMPTY_DIM_OBJ                         1  ~16     !2, 1
         10        BOOL_NOT                                         ~17     ~16
         11      > JMPZ                                                     ~17, ->14
   16    12    >   FETCH_DIM_R                                      ~18     !2, 1
         13        ASSIGN                                                   !0, ~18
   20    14    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~20     !2, 2
         15        BOOL_NOT                                         ~21     ~20
         16      > JMPZ                                                     ~21, ->19
   22    17    >   FETCH_DIM_R                                      ~22     !2, 2
         18        ASSIGN                                                   !1, ~22
   25    19    >   CONCAT                                           ~24     'Model_', !0
         20        ASSIGN                                                   !3, ~24
   26    21        CONCAT                                           ~26     'Controller_', !0
         22        ASSIGN                                                   !0, ~26
   27    23        CONCAT                                           ~28     'action_', !1
         24        ASSIGN                                                   !1, ~28
   31    25        INIT_FCALL                                               'strtolower'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $30     
         28        CONCAT                                           ~31     $30, '.php'
         29        ASSIGN                                                   !4, ~31
   32    30        CONCAT                                           ~33     'application%2Fmodels%2F', !4
         31        ASSIGN                                                   !5, ~33
   33    32        INIT_FCALL                                               'file_exists'
         33        SEND_VAR                                                 !5
         34        DO_ICALL                                         $35     
         35      > JMPZ                                                     $35, ->38
   35    36    >   CONCAT                                           ~36     'application%2Fmodels%2F', !4
         37        INCLUDE_OR_EVAL                                          ~36, INCLUDE
   39    38    >   INIT_FCALL                                               'strtolower'
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $38     
         41        CONCAT                                           ~39     $38, '.php'
         42        ASSIGN                                                   !6, ~39
   40    43        CONCAT                                           ~41     'application%2Fcontrollers%2F', !6
         44        ASSIGN                                                   !7, ~41
   41    45        INIT_FCALL                                               'file_exists'
         46        SEND_VAR                                                 !7
         47        DO_ICALL                                         $43     
         48      > JMPZ                                                     $43, ->52
   43    49    >   CONCAT                                           ~44     'application%2Fcontrollers%2F', !6
         50        INCLUDE_OR_EVAL                                          ~44, INCLUDE
         51      > JMP                                                      ->54
   48    52    >   INIT_STATIC_METHOD_CALL                                  'Route', 'ErrorPage404'
         53        DO_FCALL                                      0          
   52    54    >   FETCH_CLASS                                   0  $47     !0
         55        NEW                                              $48     $47
         56        DO_FCALL                                      0          
         57        ASSIGN                                                   !8, $48
   53    58        ASSIGN                                                   !9, !1
   55    59        INIT_FCALL                                               'method_exists'
         60        SEND_VAR                                                 !8
         61        SEND_VAR                                                 !9
         62        DO_ICALL                                         $52     
         63      > JMPZ                                                     $52, ->67
   58    64    >   INIT_METHOD_CALL                                         !8, !9
         65        DO_FCALL                                      0          
         66      > JMP                                                      ->69
   63    67    >   INIT_STATIC_METHOD_CALL                                  'Route', 'ErrorPage404'
         68        DO_FCALL                                      0          
   66    69    > > RETURN                                                   null

End of function start

Function errorpage404:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sAYpB
function name:  ErrorPage404
number of ops:  17
compiled vars:  !0 = $host
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   FETCH_R                      global              ~1      '_SERVER'
          1        FETCH_DIM_R                                      ~2      ~1, 'HTTP_HOST'
          2        CONCAT                                           ~3      'http%3A%2F%2F', ~2
          3        CONCAT                                           ~4      ~3, '%2F'
          4        ASSIGN                                                   !0, ~4
   71     5        INIT_FCALL                                               'header'
          6        SEND_VAL                                                 'HTTP%2F1.1+404+Not+Found'
          7        DO_ICALL                                                 
   72     8        INIT_FCALL                                               'header'
          9        SEND_VAL                                                 'Status%3A+404+Not+Found'
         10        DO_ICALL                                                 
   73    11        INIT_FCALL                                               'header'
         12        CONCAT                                           ~8      'Location%3A', !0
         13        CONCAT                                           ~9      ~8, '404'
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                                 
   74    16      > RETURN                                                   null

End of function errorpage404

End of class Route.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.36 ms | 1404 KiB | 23 Q