3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pre ="<a href=\""; $post= "</a>"; $in = array('http://">http', 'ftp://">ftp', 'mailto://">mailto', '#">HASH', '//">2xfw slash', '\\\\">2x Bw slash', 'file://">file' ); $replacements = array('/((?:href|src) *= *[\'"](?!(http|ftp|mailto|file|javascript|#|[a-z]+:|'. preg_quote('\\\\',"/"). '|\/\/)))(\/?)/i' => "$1" . "xxxxABSOLUTE/PATH/" ); foreach($in as $test) { echo '<br><pre>\n'; $r = $pre . $test . $post; echo "$r =>" . preg_replace(array_keys($replacements), $replacements, $r); echo '</pre>'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/j5rF9
function name:  (null)
number of ops:  33
compiled vars:  !0 = $pre, !1 = $post, !2 = $in, !3 = $replacements, !4 = $test, !5 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ca+href%3D%22'
    3     1        ASSIGN                                                   !1, '%3C%2Fa%3E'
    4     2        ASSIGN                                                   !2, <array>
   12     3        INIT_FCALL                                               'preg_quote'
          4        SEND_VAL                                                 '%5C%5C'
          5        SEND_VAL                                                 '%2F'
          6        DO_ICALL                                         $9      
          7        CONCAT                                           ~10     '%2F%28%28%3F%3Ahref%7Csrc%29+%2A%3D+%2A%5B%27%22%5D%28%3F%21%28http%7Cftp%7Cmailto%7Cfile%7Cjavascript%7C%23%7C%5Ba-z%5D%2B%3A%7C', $9
          8        CONCAT                                           ~11     ~10, '%7C%5C%2F%5C%2F%29%29%29%28%5C%2F%3F%29%2Fi'
   13     9        INIT_ARRAY                                       ~12     '%241xxxxABSOLUTE%2FPATH%2F', ~11
   12    10        ASSIGN                                                   !3, ~12
   16    11      > FE_RESET_R                                       $14     !2, ->31
         12    > > FE_FETCH_R                                               $14, !4, ->31
   17    13    >   ECHO                                                     '%3Cbr%3E%3Cpre%3E%5Cn'
   18    14        CONCAT                                           ~15     !0, !4
         15        CONCAT                                           ~16     ~15, !1
         16        ASSIGN                                                   !5, ~16
   19    17        NOP                                                      
         18        FAST_CONCAT                                      ~18     !5, '+%3D%3E'
         19        INIT_FCALL                                               'preg_replace'
         20        INIT_FCALL                                               'array_keys'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $19     
         23        SEND_VAR                                                 $19
         24        SEND_VAR                                                 !3
         25        SEND_VAR                                                 !5
         26        DO_ICALL                                         $20     
         27        CONCAT                                           ~21     ~18, $20
         28        ECHO                                                     ~21
   20    29        ECHO                                                     '%3C%2Fpre%3E'
   16    30      > JMP                                                      ->12
         31    >   FE_FREE                                                  $14
   21    32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.43 ms | 1396 KiB | 19 Q