3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tokenStream = []; // [tokenName, lexeme] pairs $input = <<<'end' $a = 3; // variable initialisation end; // Pre PHP 7 code preg_replace_callback( [ '~\$[a-z_][a-z\d_]*~i', '~=~', '~[\d]+~', '~;~', '~//.*~' ], function ($match) use (&$tokenStream) { if (strpos($match[0], '$') === 0) { $tokenStream[] = ['T_VARIABLE', $match[0]]; } elseif (strpos($match[0], '=') === 0) { $tokenStream[] = ['T_ASSIGN', $match[0]]; } elseif (ctype_digit($match[0])) { $tokenStream[] = ['T_NUM', $match[0]]; } elseif (strpos($match[0], ';') === 0) { $tokenStream[] = ['T_TERMINATE_STMT', $match[0]]; } elseif (strpos($match[0], '//') === 0) { $tokenStream[] = ['T_COMMENT', $match[0]]; } }, $input ); // PHP 7+ code preg_replace_callback_array( [ '~\$[a-z_][a-z\d_]*~i' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_VARIABLE', $match[0]]; }, '~=~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_ASSIGN', $match[0]]; }, '~[\d]+~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_NUM', $match[0]]; }, '~;~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_TERMINATE_STMT', $match[0]]; }, '~//.*~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_COMMENT', $match[0]]; } ], $input );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qkvvr
function name:  (null)
number of ops:  29
compiled vars:  !0 = $tokenStream, !1 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, '%24a+%3D+3%3B+%2F%2F+variable+initialisation'
   10     2        INIT_FCALL                                               'preg_replace_callback'
   12     3        SEND_VAL                                                 <array>
   18     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fqkvvr%3A18%240'
          5        BIND_LEXICAL                                             ~4, !0
   30     6        SEND_VAL                                                 ~4
   31     7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   35     9        INIT_FCALL                                               'preg_replace_callback_array'
   37    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fqkvvr%3A37%241'
         11        BIND_LEXICAL                                             ~6, !0
   39    12        INIT_ARRAY                                       ~7      ~6, '%7E%5C%24%5Ba-z_%5D%5Ba-z%5Cd_%5D%2A%7Ei'
   40    13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fqkvvr%3A40%242'
         14        BIND_LEXICAL                                             ~8, !0
   42    15        ADD_ARRAY_ELEMENT                                ~7      ~8, '%7E%3D%7E'
   43    16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fqkvvr%3A43%243'
         17        BIND_LEXICAL                                             ~9, !0
   45    18        ADD_ARRAY_ELEMENT                                ~7      ~9, '%7E%5B%5Cd%5D%2B%7E'
   46    19        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fqkvvr%3A46%244'
         20        BIND_LEXICAL                                             ~10, !0
   48    21        ADD_ARRAY_ELEMENT                                ~7      ~10, '%7E%3B%7E'
   49    22        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fqkvvr%3A49%245'
         23        BIND_LEXICAL                                             ~11, !0
   51    24        ADD_ARRAY_ELEMENT                                ~7      ~11, '%7E%2F%2F.%2A%7E'
         25        SEND_VAL                                                 ~7
   53    26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
   54    28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A18%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 52
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 64
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
filename:       /in/qkvvr
function name:  {closure}
number of ops:  65
compiled vars:  !0 = $match, !1 = $tokenStream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   19     2        INIT_FCALL                                               'strpos'
          3        FETCH_DIM_R                                      ~2      !0, 0
          4        SEND_VAL                                                 ~2
          5        SEND_VAL                                                 '%24'
          6        DO_ICALL                                         $3      
          7        IS_IDENTICAL                                             $3, 0
          8      > JMPZ                                                     ~4, ->15
   20     9    >   INIT_ARRAY                                       ~6      'T_VARIABLE'
         10        FETCH_DIM_R                                      ~7      !0, 0
         11        ADD_ARRAY_ELEMENT                                ~6      ~7
         12        ASSIGN_DIM                                               !1
         13        OP_DATA                                                  ~6
         14      > JMP                                                      ->64
   21    15    >   INIT_FCALL                                               'strpos'
         16        FETCH_DIM_R                                      ~8      !0, 0
         17        SEND_VAL                                                 ~8
         18        SEND_VAL                                                 '%3D'
         19        DO_ICALL                                         $9      
         20        IS_IDENTICAL                                             $9, 0
         21      > JMPZ                                                     ~10, ->28
   22    22    >   INIT_ARRAY                                       ~12     'T_ASSIGN'
         23        FETCH_DIM_R                                      ~13     !0, 0
         24        ADD_ARRAY_ELEMENT                                ~12     ~13
         25        ASSIGN_DIM                                               !1
         26        OP_DATA                                                  ~12
         27      > JMP                                                      ->64
   23    28    >   INIT_FCALL                                               'ctype_digit'
         29        FETCH_DIM_R                                      ~14     !0, 0
         30        SEND_VAL                                                 ~14
         31        DO_ICALL                                         $15     
         32      > JMPZ                                                     $15, ->39
   24    33    >   INIT_ARRAY                                       ~17     'T_NUM'
         34        FETCH_DIM_R                                      ~18     !0, 0
         35        ADD_ARRAY_ELEMENT                                ~17     ~18
         36        ASSIGN_DIM                                               !1
         37        OP_DATA                                                  ~17
         38      > JMP                                                      ->64
   25    39    >   INIT_FCALL                                               'strpos'
         40        FETCH_DIM_R                                      ~19     !0, 0
         41        SEND_VAL                                                 ~19
         42        SEND_VAL                                                 '%3B'
         43        DO_ICALL                                         $20     
         44        IS_IDENTICAL                                             $20, 0
         45      > JMPZ                                                     ~21, ->52
   26    46    >   INIT_ARRAY                                       ~23     'T_TERMINATE_STMT'
         47        FETCH_DIM_R                                      ~24     !0, 0
         48        ADD_ARRAY_ELEMENT                                ~23     ~24
         49        ASSIGN_DIM                                               !1
         50        OP_DATA                                                  ~23
         51      > JMP                                                      ->64
   27    52    >   INIT_FCALL                                               'strpos'
         53        FETCH_DIM_R                                      ~25     !0, 0
         54        SEND_VAL                                                 ~25
         55        SEND_VAL                                                 '%2F%2F'
         56        DO_ICALL                                         $26     
         57        IS_IDENTICAL                                             $26, 0
         58      > JMPZ                                                     ~27, ->64
   28    59    >   INIT_ARRAY                                       ~29     'T_COMMENT'
         60        FETCH_DIM_R                                      ~30     !0, 0
         61        ADD_ARRAY_ELEMENT                                ~29     ~30
         62        ASSIGN_DIM                                               !1
         63        OP_DATA                                                  ~29
   30    64    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A18%240

Function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A37%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qkvvr
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $match, !1 = $tokenStream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   38     2        INIT_ARRAY                                       ~3      'T_VARIABLE'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        ADD_ARRAY_ELEMENT                                ~3      ~4
          5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  ~3
   39     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A37%241

Function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A40%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qkvvr
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $match, !1 = $tokenStream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   41     2        INIT_ARRAY                                       ~3      'T_ASSIGN'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        ADD_ARRAY_ELEMENT                                ~3      ~4
          5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  ~3
   42     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A40%242

Function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A43%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qkvvr
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $match, !1 = $tokenStream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   44     2        INIT_ARRAY                                       ~3      'T_NUM'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        ADD_ARRAY_ELEMENT                                ~3      ~4
          5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  ~3
   45     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A43%243

Function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A46%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qkvvr
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $match, !1 = $tokenStream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   47     2        INIT_ARRAY                                       ~3      'T_TERMINATE_STMT'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        ADD_ARRAY_ELEMENT                                ~3      ~4
          5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  ~3
   48     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A46%244

Function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A49%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qkvvr
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $match, !1 = $tokenStream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   50     2        INIT_ARRAY                                       ~3      'T_COMMENT'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        ADD_ARRAY_ELEMENT                                ~3      ~4
          5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  ~3
   51     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fqkvvr%3A49%245

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.38 ms | 1413 KiB | 21 Q