3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replace($string) { return preg_replace_callback('/(?<tag>(?<enter><)?!(?<level>\d+)!(?<leave>>)?)/', function ($match) { $level = (int) $match['level']; $enter = !empty($match['enter']); $leave = !empty($match['leave']); if ($enter === $leave) { var_dump($match); return $match['tag']; } if ($level > 0) { return vsprintf('%s!%d!%s', [ $enter ? '<' : null, $level - 1, $leave ? '>' : null, ]); } return vsprintf('%s?%s', [ $enter ? '<' : null, $leave ? '>' : null, ]); }, $string); } $string = '<!3!= "<!2!= "<!1!= "<!0!= "noodles" !0!>" !1!>" !2!>" !3!>'; ob_start(); eval(sprintf('; ?>%s<?php ', replace($string))); $string = ob_get_clean(); echo $string . PHP_EOL; ob_start(); eval(sprintf('; ?>%s<?php ', replace($string))); $string = ob_get_clean(); echo $string . PHP_EOL; ob_start(); eval(sprintf('; ?>%s<?php ', replace($string))); $string = ob_get_clean(); echo $string . PHP_EOL; ob_start(); eval(sprintf('; ?>%s<?php ', replace($string))); $string = ob_get_clean(); echo $string . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PJktm
function name:  (null)
number of ops:  62
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, '%3C%213%21%3D+%22%3C%212%21%3D+%22%3C%211%21%3D+%22%3C%210%21%3D+%22noodles%22+%210%21%3E%22+%211%21%3E%22+%212%21%3E%22+%213%21%3E'
   31     1        INIT_FCALL                                               'ob_start'
          2        DO_ICALL                                                 
   32     3        INIT_FCALL                                               'sprintf'
          4        SEND_VAL                                                 '%3B+%3F%3E%25s%3C%3Fphp+'
          5        INIT_FCALL                                               'replace'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                         $4      
         10        INCLUDE_OR_EVAL                                          $4, EVAL
   33    11        INIT_FCALL                                               'ob_get_clean'
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !0, $6
   34    14        CONCAT                                           ~8      !0, '%0A'
         15        ECHO                                                     ~8
   36    16        INIT_FCALL                                               'ob_start'
         17        DO_ICALL                                                 
   37    18        INIT_FCALL                                               'sprintf'
         19        SEND_VAL                                                 '%3B+%3F%3E%25s%3C%3Fphp+'
         20        INIT_FCALL                                               'replace'
         21        SEND_VAR                                                 !0
         22        DO_FCALL                                      0  $10     
         23        SEND_VAR                                                 $10
         24        DO_ICALL                                         $11     
         25        INCLUDE_OR_EVAL                                          $11, EVAL
   38    26        INIT_FCALL                                               'ob_get_clean'
         27        DO_ICALL                                         $13     
         28        ASSIGN                                                   !0, $13
   39    29        CONCAT                                           ~15     !0, '%0A'
         30        ECHO                                                     ~15
   41    31        INIT_FCALL                                               'ob_start'
         32        DO_ICALL                                                 
   42    33        INIT_FCALL                                               'sprintf'
         34        SEND_VAL                                                 '%3B+%3F%3E%25s%3C%3Fphp+'
         35        INIT_FCALL                                               'replace'
         36        SEND_VAR                                                 !0
         37        DO_FCALL                                      0  $17     
         38        SEND_VAR                                                 $17
         39        DO_ICALL                                         $18     
         40        INCLUDE_OR_EVAL                                          $18, EVAL
   43    41        INIT_FCALL                                               'ob_get_clean'
         42        DO_ICALL                                         $20     
         43        ASSIGN                                                   !0, $20
   44    44        CONCAT                                           ~22     !0, '%0A'
         45        ECHO                                                     ~22
   46    46        INIT_FCALL                                               'ob_start'
         47        DO_ICALL                                                 
   47    48        INIT_FCALL                                               'sprintf'
         49        SEND_VAL                                                 '%3B+%3F%3E%25s%3C%3Fphp+'
         50        INIT_FCALL                                               'replace'
         51        SEND_VAR                                                 !0
         52        DO_FCALL                                      0  $24     
         53        SEND_VAR                                                 $24
         54        DO_ICALL                                         $25     
         55        INCLUDE_OR_EVAL                                          $25, EVAL
   48    56        INIT_FCALL                                               'ob_get_clean'
         57        DO_ICALL                                         $27     
         58        ASSIGN                                                   !0, $27
   49    59        CONCAT                                           ~29     !0, '%0A'
         60        ECHO                                                     ~29
         61      > RETURN                                                   1

Function replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PJktm
function name:  replace
number of ops:  9
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%2F%28%3F%3Ctag%3E%28%3F%3Center%3E%3C%29%3F%21%28%3F%3Clevel%3E%5Cd%2B%29%21%28%3F%3Cleave%3E%3E%29%3F%29%2F'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FPJktm%3A5%240'
   26     4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   27     8*     > RETURN                                                   null

End of function replace

Function %00%7Bclosure%7D%2Fin%2FPJktm%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
Branch analysis from position: 31
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
Branch analysis from position: 46
filename:       /in/PJktm
function name:  {closure}
number of ops:  52
compiled vars:  !0 = $match, !1 = $level, !2 = $enter, !3 = $leave
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        FETCH_DIM_R                                      ~4      !0, 'level'
          2        CAST                                          4  ~5      ~4
          3        ASSIGN                                                   !1, ~5
    7     4        ISSET_ISEMPTY_DIM_OBJ                         1  ~7      !0, 'enter'
          5        BOOL_NOT                                         ~8      ~7
          6        ASSIGN                                                   !2, ~8
    8     7        ISSET_ISEMPTY_DIM_OBJ                         1  ~10     !0, 'leave'
          8        BOOL_NOT                                         ~11     ~10
          9        ASSIGN                                                   !3, ~11
    9    10        IS_IDENTICAL                                             !2, !3
         11      > JMPZ                                                     ~13, ->17
   11    12    >   INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   12    15        FETCH_DIM_R                                      ~15     !0, 'tag'
         16      > RETURN                                                   ~15
   14    17    >   IS_SMALLER                                               0, !1
         18      > JMPZ                                                     ~16, ->36
   16    19    >   INIT_FCALL                                               'vsprintf'
         20        SEND_VAL                                                 '%25s%21%25d%21%25s'
   17    21      > JMPZ                                                     !2, ->24
         22    >   QM_ASSIGN                                        ~17     '%3C'
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~17     null
         25    >   INIT_ARRAY                                       ~18     ~17
   18    26        SUB                                              ~19     !1, 1
         27        ADD_ARRAY_ELEMENT                                ~18     ~19
   19    28      > JMPZ                                                     !3, ->31
         29    >   QM_ASSIGN                                        ~20     '%3E'
         30      > JMP                                                      ->32
   17    31    >   QM_ASSIGN                                        ~20     null
         32    >   ADD_ARRAY_ELEMENT                                ~18     ~20
         33        SEND_VAL                                                 ~18
         34        DO_ICALL                                         $21     
         35      > RETURN                                                   $21
   22    36    >   INIT_FCALL                                               'vsprintf'
         37        SEND_VAL                                                 '%25s%3F%25s'
   23    38      > JMPZ                                                     !2, ->41
         39    >   QM_ASSIGN                                        ~22     '%3C'
         40      > JMP                                                      ->42
         41    >   QM_ASSIGN                                        ~22     null
         42    >   INIT_ARRAY                                       ~23     ~22
   24    43      > JMPZ                                                     !3, ->46
         44    >   QM_ASSIGN                                        ~24     '%3E'
         45      > JMP                                                      ->47
   23    46    >   QM_ASSIGN                                        ~24     null
         47    >   ADD_ARRAY_ELEMENT                                ~23     ~24
         48        SEND_VAL                                                 ~23
         49        DO_ICALL                                         $25     
         50      > RETURN                                                   $25
   26    51*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FPJktm%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.04 ms | 1410 KiB | 29 Q