3v4l.org

run code in 300+ PHP versions simultaneously
<?php assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_BAIL, 1); $mf = function () { /** * Used to store functions and allow recursive callbacks. * @var null|callback */ static $deploy = null; /** * Defined matches. * @var array */ static $ms = array(); /** * Dependency Injection callbacks, used for settings too. * @var array */ static $di = array(); // used to shorten code $num_args = func_num_args(); $get_args = func_get_args(); // used to retrieve currently defined matches // http://www.php.net/manual/en/regexp.reference.conditional.php // http://stackoverflow.com/questions/14598972/catch-all-regular-expression if ($num_args === 0 && PHP_SAPI !== 'cli') { return '/?(?!(' . implode('|', $ms) . ')$).*'; } elseif ($num_args === 2 && is_scalar($get_args[0]) && preg_match('#^[^/].+#', $get_args[0])) { // functions used for Dependency Injection and settings return $di[$get_args[0]] = $get_args[1]; } elseif ($num_args === 1 && is_scalar($get_args[0]) && preg_match('#^[^/].+#', $get_args[0])) { return is_callable($di[$get_args[0]]) ? call_user_func($di[$get_args[0]]) : $di[$get_args[0]]; } // functions have to be stored only once if (is_null($deploy) && PHP_SAPI === 'cli') { /** * Command line interface for the main function. * * @link http://php.net/manual/en/language.types.float.php * * @param callback $callback Function invoked when script ends * @param integer $priority Set `$callback` priority from 0 (high) to ~1.8e308 (low) * @return void */ $deploy = function ($callback, $priority = 0) use (&$deploy) { /** * Checking well formed call */ assert(is_callable($callback)); assert(is_numeric($priority)); /** * Arguments passed to the script. * @link http://php.net/manual/en/reserved.variables.argv.php * @var array */ $argv = $GLOBALS['argv']; if ($priority > 0) { /** * Recursion is used to set callback priority */ register_shutdown_function($deploy, $callback, $priority - 1); } else { $argv[0] = $callback; /** * register_shutdown_function is used to call added functions when script ends * @link http://it2.php.net/manual/en/function.register-shutdown-function.php */ call_user_func_array('register_shutdown_function', $argv); } }; } elseif (is_null($deploy)) { /** * Function used as a router. * * @link http://php.net/manual/en/language.types.float.php * * @param string $regex Regular expression used to match requested URL * @param callback $callback Function invoked when there's a match * @param string $method Request method(s) * @param float $priority Set `$callback` priority from 0 (high) to ~1.8e308 (low) * @return void */ $deploy = function ($regex, $callback, $method = 'GET', $priority = 0) use (&$deploy, &$ms) { /** * Checking well formed call */ assert(is_string($regex)); assert(is_callable($callback)); assert(is_string($method)); assert(is_numeric($priority)); // match stored as unique $ms[md5($regex)] = $regex; if ($priority > 0) { /** * Recursion is used to set callback priority */ register_shutdown_function($deploy, $regex, $callback, $method, $priority - 1); } elseif (preg_match('#' . $method . '#', $_SERVER['REQUEST_METHOD'])) { if (preg_match('#^' . $regex . '$#', $_SERVER['REQUEST_URI'], $matches)) { /** * Named subpatterns aren't allowed * @link http://it2.php.net/manual/en/regexp.reference.subpatterns.php */ while (list($key) = each($matches)) { if (!is_int($key)) { unset($matches[$key]); } } /** * Closure is added to `register_shutdown_function` calling */ if (isset($matches[0]) && $matches[0] === $_SERVER['REQUEST_URI']) { $matches[0] = $callback; } else { array_unshift($matches, $callback); } /** * register_shutdown_function is used to call added functions when script ends * @link http://it2.php.net/manual/en/function.register-shutdown-function.php */ call_user_func_array('register_shutdown_function', $matches); } } }; } return call_user_func_array($deploy, func_get_args()); }; $mf(function () { echo "Hello "; }); $mf(function () { echo "World!"; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VJtC8
function name:  (null)
number of ops:  19
compiled vars:  !0 = $mf
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'assert_options'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 1
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'assert_options'
          5        SEND_VAL                                                 3
          6        SEND_VAL                                                 1
          7        DO_ICALL                                                 
    6     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVJtC8%3A6%240'
          9        ASSIGN                                                   !0, ~3
  141    10        INIT_DYNAMIC_CALL                                        !0
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVJtC8%3A141%243'
  143    12        SEND_VAL_EX                                              ~5
         13        DO_FCALL                                      0          
  144    14        INIT_DYNAMIC_CALL                                        !0
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVJtC8%3A144%244'
  146    16        SEND_VAL_EX                                              ~7
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FVJtC8%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 46) Position 1 = 44, Position 2 = 50
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 67
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
2 jumps found. (Code = 46) Position 1 = 69, Position 2 = 70
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 75
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 81
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
Branch analysis from position: 70
Branch analysis from position: 50
Branch analysis from position: 43
Branch analysis from position: 31
Branch analysis from position: 24
Branch analysis from position: 10
filename:       /in/VJtC8
function name:  {closure}
number of ops:  88
compiled vars:  !0 = $deploy, !1 = $ms, !2 = $di, !3 = $num_args, !4 = $get_args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   BIND_STATIC                                              !0
   16     1        BIND_STATIC                                              !1
   21     2        BIND_STATIC                                              !2
   24     3        FUNC_NUM_ARGS                                    ~5      
          4        ASSIGN                                                   !3, ~5
   25     5        FUNC_GET_ARGS                                    ~7      
          6        ASSIGN                                                   !4, ~7
   30     7        IS_IDENTICAL                                     ~9      !3, 0
          8      > JMPZ_EX                                          ~9      ~9, ->10
          9    >   BOOL                                             ~9      <false>
         10    > > JMPZ                                                     ~9, ->19
   31    11    >   INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '%7C'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $10     
         15        CONCAT                                           ~11     '%2F%3F%28%3F%21%28', $10
         16        CONCAT                                           ~12     ~11, '%29%24%29.%2A'
         17      > RETURN                                                   ~12
         18*       JMP                                                      ->67
   32    19    >   IS_IDENTICAL                                     ~13     !3, 2
         20      > JMPZ_EX                                          ~13     ~13, ->24
         21    >   FETCH_DIM_R                                      ~14     !4, 0
         22        TYPE_CHECK                                  124  ~15     ~14
         23        BOOL                                             ~13     ~15
         24    > > JMPZ_EX                                          ~13     ~13, ->31
         25    >   INIT_FCALL                                               'preg_match'
         26        SEND_VAL                                                 '%23%5E%5B%5E%2F%5D.%2B%23'
         27        FETCH_DIM_R                                      ~16     !4, 0
         28        SEND_VAL                                                 ~16
         29        DO_ICALL                                         $17     
         30        BOOL                                             ~13     $17
         31    > > JMPZ                                                     ~13, ->38
   34    32    >   FETCH_DIM_R                                      ~18     !4, 0
         33        FETCH_DIM_R                                      ~20     !4, 1
         34        ASSIGN_DIM                                       ~19     !2, ~18
         35        OP_DATA                                                  ~20
         36      > RETURN                                                   ~19
         37*       JMP                                                      ->67
   35    38    >   IS_IDENTICAL                                     ~21     !3, 1
         39      > JMPZ_EX                                          ~21     ~21, ->43
         40    >   FETCH_DIM_R                                      ~22     !4, 0
         41        TYPE_CHECK                                  124  ~23     ~22
         42        BOOL                                             ~21     ~23
         43    > > JMPZ_EX                                          ~21     ~21, ->50
         44    >   INIT_FCALL                                               'preg_match'
         45        SEND_VAL                                                 '%23%5E%5B%5E%2F%5D.%2B%23'
         46        FETCH_DIM_R                                      ~24     !4, 0
         47        SEND_VAL                                                 ~24
         48        DO_ICALL                                         $25     
         49        BOOL                                             ~21     $25
         50    > > JMPZ                                                     ~21, ->67
   36    51    >   INIT_FCALL                                               'is_callable'
         52        FETCH_DIM_R                                      ~26     !4, 0
         53        FETCH_DIM_R                                      ~27     !2, ~26
         54        SEND_VAL                                                 ~27
         55        DO_ICALL                                         $28     
         56      > JMPZ                                                     $28, ->63
   37    57    >   FETCH_DIM_R                                      ~29     !4, 0
         58        FETCH_DIM_R                                      ~30     !2, ~29
         59        INIT_USER_CALL                                0          'call_user_func', ~30
         60        DO_FCALL                                      0  $31     
         61        QM_ASSIGN                                        ~32     $31
         62      > JMP                                                      ->66
   38    63    >   FETCH_DIM_R                                      ~33     !4, 0
         64        FETCH_DIM_R                                      ~34     !2, ~33
         65        QM_ASSIGN                                        ~32     ~34
         66    > > RETURN                                                   ~32
   42    67    >   TYPE_CHECK                                    2  ~35     !0
         68      > JMPZ_EX                                          ~35     ~35, ->70
         69    >   BOOL                                             ~35     <true>
         70    > > JMPZ                                                     ~35, ->75
   52    71    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVJtC8%3A52%241'
         72        BIND_LEXICAL                                             ~36, !0
         73        ASSIGN                                                   !0, ~36
         74      > JMP                                                      ->81
   80    75    >   TYPE_CHECK                                    2          !0
         76      > JMPZ                                                     ~38, ->81
   92    77    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVJtC8%3A92%242'
         78        BIND_LEXICAL                                             ~39, !0
         79        BIND_LEXICAL                                             ~39, !1
         80        ASSIGN                                                   !0, ~39
  138    81    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         82        FUNC_GET_ARGS                                    ~41     
         83        SEND_ARRAY                                               ~41
         84        CHECK_UNDEF_ARGS                                         
         85        DO_FCALL                                      0  $42     
         86      > RETURN                                                   $42
  139    87*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVJtC8%3A6%240

Function %00%7Bclosure%7D%2Fin%2FVJtC8%3A52%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VJtC8
function name:  {closure}
number of ops:  38
compiled vars:  !0 = $callback, !1 = $priority, !2 = $deploy, !3 = $argv
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        BIND_STATIC                                              !2
   56     3        ASSERT_CHECK                                             
          4        INIT_FCALL                                               'assert'
          5        INIT_FCALL                                               'is_callable'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        SEND_VAL                                                 'assert%28is_callable%28%24callback%29%29'
         10        DO_ICALL                                                 
   57    11        ASSERT_CHECK                                             
         12        INIT_FCALL                                               'assert'
         13        INIT_FCALL                                               'is_numeric'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        SEND_VAL                                                 'assert%28is_numeric%28%24priority%29%29'
         18        DO_ICALL                                                 
   64    19        FETCH_R                      global              ~8      'GLOBALS'
         20        FETCH_DIM_R                                      ~9      ~8, 'argv'
         21        ASSIGN                                                   !3, ~9
   66    22        IS_SMALLER                                               0, !1
         23      > JMPZ                                                     ~11, ->31
   70    24    >   INIT_FCALL                                               'register_shutdown_function'
         25        SEND_VAR                                                 !2
         26        SEND_VAR                                                 !0
         27        SUB                                              ~12     !1, 1
         28        SEND_VAL                                                 ~12
         29        DO_ICALL                                                 
         30      > JMP                                                      ->37
   72    31    >   ASSIGN_DIM                                               !3, 0
         32        OP_DATA                                                  !0
   77    33        INIT_FCALL                                               'register_shutdown_function'
         34        SEND_ARRAY                                               !3
         35        CHECK_UNDEF_ARGS                                         
         36        DO_FCALL                                      0          
   79    37    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVJtC8%3A52%241

Function %00%7Bclosure%7D%2Fin%2FVJtC8%3A92%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 50
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 99
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 99
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 70
Branch analysis from position: 80
2 jumps found. (Code = 46) Position 1 = 82, Position 2 = 87
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 91
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 87
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 74
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 70
Branch analysis from position: 80
Branch analysis from position: 70
Branch analysis from position: 74
Branch analysis from position: 99
Branch analysis from position: 99
filename:       /in/VJtC8
function name:  {closure}
number of ops:  100
compiled vars:  !0 = $regex, !1 = $callback, !2 = $method, !3 = $priority, !4 = $deploy, !5 = $ms, !6 = $matches, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      'GET'
          3        RECV_INIT                                        !3      0
          4        BIND_STATIC                                              !4
          5        BIND_STATIC                                              !5
   96     6        ASSERT_CHECK                                             
          7        INIT_FCALL                                               'assert'
          8        TYPE_CHECK                                   64  ~8      !0
          9        SEND_VAL                                                 ~8
         10        SEND_VAL                                                 'assert%28is_string%28%24regex%29%29'
         11        DO_ICALL                                                 
   97    12        ASSERT_CHECK                                             
         13        INIT_FCALL                                               'assert'
         14        INIT_FCALL                                               'is_callable'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $10     
         17        SEND_VAR                                                 $10
         18        SEND_VAL                                                 'assert%28is_callable%28%24callback%29%29'
         19        DO_ICALL                                                 
   98    20        ASSERT_CHECK                                             
         21        INIT_FCALL                                               'assert'
         22        TYPE_CHECK                                   64  ~12     !2
         23        SEND_VAL                                                 ~12
         24        SEND_VAL                                                 'assert%28is_string%28%24method%29%29'
         25        DO_ICALL                                                 
   99    26        ASSERT_CHECK                                             
         27        INIT_FCALL                                               'assert'
         28        INIT_FCALL                                               'is_numeric'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                         $14     
         31        SEND_VAR                                                 $14
         32        SEND_VAL                                                 'assert%28is_numeric%28%24priority%29%29'
         33        DO_ICALL                                                 
  102    34        INIT_FCALL                                               'md5'
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $16     
         37        ASSIGN_DIM                                               !5, $16
         38        OP_DATA                                                  !0
  104    39        IS_SMALLER                                               0, !3
         40      > JMPZ                                                     ~18, ->50
  108    41    >   INIT_FCALL                                               'register_shutdown_function'
         42        SEND_VAR                                                 !4
         43        SEND_VAR                                                 !0
         44        SEND_VAR                                                 !1
         45        SEND_VAR                                                 !2
         46        SUB                                              ~19     !3, 1
         47        SEND_VAL                                                 ~19
         48        DO_ICALL                                                 
         49      > JMP                                                      ->99
  109    50    >   INIT_FCALL                                               'preg_match'
         51        CONCAT                                           ~21     '%23', !2
         52        CONCAT                                           ~22     ~21, '%23'
         53        SEND_VAL                                                 ~22
         54        FETCH_R                      global              ~23     '_SERVER'
         55        FETCH_DIM_R                                      ~24     ~23, 'REQUEST_METHOD'
         56        SEND_VAL                                                 ~24
         57        DO_ICALL                                         $25     
         58      > JMPZ                                                     $25, ->99
  110    59    >   INIT_FCALL                                               'preg_match'
         60        CONCAT                                           ~26     '%23%5E', !0
         61        CONCAT                                           ~27     ~26, '%24%23'
         62        SEND_VAL                                                 ~27
         63        FETCH_R                      global              ~28     '_SERVER'
         64        FETCH_DIM_R                                      ~29     ~28, 'REQUEST_URI'
         65        SEND_VAL                                                 ~29
         66        SEND_REF                                                 !6
         67        DO_ICALL                                         $30     
         68      > JMPZ                                                     $30, ->99
  115    69    > > JMP                                                      ->74
  116    70    >   TYPE_CHECK                                   16  ~31     !7
         71        BOOL_NOT                                         ~32     ~31
         72      > JMPZ                                                     ~32, ->74
  117    73    >   UNSET_DIM                                                !6, !7
  115    74    >   INIT_FCALL_BY_NAME                                       'each'
         75        SEND_VAR_EX                                              !6
         76        DO_FCALL                                      0  $33     
         77        FETCH_LIST_R                                     $34     $33, 0
         78        ASSIGN                                                   !7, $34
         79      > JMPNZ                                                    $33, ->70
  123    80    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~36     !6, 0
         81      > JMPZ_EX                                          ~36     ~36, ->87
         82    >   FETCH_DIM_R                                      ~37     !6, 0
         83        FETCH_R                      global              ~38     '_SERVER'
         84        FETCH_DIM_R                                      ~39     ~38, 'REQUEST_URI'
         85        IS_IDENTICAL                                     ~40     ~37, ~39
         86        BOOL                                             ~36     ~40
         87    > > JMPZ                                                     ~36, ->91
  124    88    >   ASSIGN_DIM                                               !6, 0
         89        OP_DATA                                                  !1
         90      > JMP                                                      ->95
  126    91    >   INIT_FCALL                                               'array_unshift'
         92        SEND_REF                                                 !6
         93        SEND_VAR                                                 !1
         94        DO_ICALL                                                 
  132    95    >   INIT_FCALL                                               'register_shutdown_function'
         96        SEND_ARRAY                                               !6
         97        CHECK_UNDEF_ARGS                                         
         98        DO_FCALL                                      0          
  135    99    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVJtC8%3A92%242

Function %00%7Bclosure%7D%2Fin%2FVJtC8%3A141%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VJtC8
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  142     0  E >   ECHO                                                     'Hello+'
  143     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVJtC8%3A141%243

Function %00%7Bclosure%7D%2Fin%2FVJtC8%3A144%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VJtC8
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  145     0  E >   ECHO                                                     'World%21'
  146     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVJtC8%3A144%244

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.93 ms | 1420 KiB | 37 Q