3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '/(?:src|href)\=(?:\\\'|")([^\\\'"]+)(?:\\\'|")/'; $source = <<<SRC <a href="http://www.sape.ru">some text</a> <img src='logo.jpg' alt=''></a> SRC; $baseUrl = 'http://www.sape.ru'; $callback = function($matches) use ($baseUrl) { $srcTag = $matches[0]; $url = $matches[1]; $url = str_replace('../', '', $url); $url = str_replace('./', '', $url); $url = str_replace('//', '', $url); $path = parse_url($url, PHP_URL_PATH); if (empty($path)) { $path = '/'; } $query = parse_url($url, PHP_URL_QUERY); if (!empty($query)) { $path.= '?' . $query; } $fragment = parse_url($url, PHP_URL_FRAGMENT); if (!empty($fragment)) { $path.= '#' . $fragment; } $resultUrl = $baseUrl . $path; var_dump($resultUrl); return $resultUrl; }; preg_replace_callback($pattern, $callback, $source);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yr5MR
function name:  (null)
number of ops:  12
compiled vars:  !0 = $pattern, !1 = $source, !2 = $baseUrl, !3 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%28%3F%3Asrc%7Chref%29%5C%3D%28%3F%3A%5C%27%7C%22%29%28%5B%5E%5C%27%22%5D%2B%29%28%3F%3A%5C%27%7C%22%29%2F'
    5     1        ASSIGN                                                   !1, '%0A%3Ca+href%3D%22http%3A%2F%2Fwww.sape.ru%22%3Esome+text%3C%2Fa%3E%0A%0A%3Cimg+src%3D%27logo.jpg%27+alt%3D%27%27%3E%3C%2Fa%3E%0A'
   14     2        ASSIGN                                                   !2, 'http%3A%2F%2Fwww.sape.ru'
   16     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYr5MR%3A16%240'
          4        BIND_LEXICAL                                             ~7, !2
          5        ASSIGN                                                   !3, ~7
   51     6        INIT_FCALL                                               'preg_replace_callback'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !3
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FYr5MR%3A16%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
Branch analysis from position: 42
Branch analysis from position: 32
filename:       /in/Yr5MR
function name:  {closure}
number of ops:  59
compiled vars:  !0 = $matches, !1 = $baseUrl, !2 = $srcTag, !3 = $url, !4 = $path, !5 = $query, !6 = $fragment, !7 = $resultUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   18     2        FETCH_DIM_R                                      ~8      !0, 0
          3        ASSIGN                                                   !2, ~8
   19     4        FETCH_DIM_R                                      ~10     !0, 1
          5        ASSIGN                                                   !3, ~10
   21     6        INIT_FCALL                                               'str_replace'
          7        SEND_VAL                                                 '..%2F'
          8        SEND_VAL                                                 ''
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $12     
         11        ASSIGN                                                   !3, $12
   22    12        INIT_FCALL                                               'str_replace'
         13        SEND_VAL                                                 '.%2F'
         14        SEND_VAL                                                 ''
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !3, $14
   23    18        INIT_FCALL                                               'str_replace'
         19        SEND_VAL                                                 '%2F%2F'
         20        SEND_VAL                                                 ''
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $16     
         23        ASSIGN                                                   !3, $16
   26    24        INIT_FCALL                                               'parse_url'
         25        SEND_VAR                                                 !3
         26        SEND_VAL                                                 5
         27        DO_ICALL                                         $18     
         28        ASSIGN                                                   !4, $18
   27    29        ISSET_ISEMPTY_CV                                         !4
         30      > JMPZ                                                     ~20, ->32
   28    31    >   ASSIGN                                                   !4, '%2F'
   31    32    >   INIT_FCALL                                               'parse_url'
         33        SEND_VAR                                                 !3
         34        SEND_VAL                                                 6
         35        DO_ICALL                                         $22     
         36        ASSIGN                                                   !5, $22
   32    37        ISSET_ISEMPTY_CV                                 ~24     !5
         38        BOOL_NOT                                         ~25     ~24
         39      > JMPZ                                                     ~25, ->42
   33    40    >   CONCAT                                           ~26     '%3F', !5
         41        ASSIGN_OP                                     8          !4, ~26
   37    42    >   INIT_FCALL                                               'parse_url'
         43        SEND_VAR                                                 !3
         44        SEND_VAL                                                 7
         45        DO_ICALL                                         $28     
         46        ASSIGN                                                   !6, $28
   38    47        ISSET_ISEMPTY_CV                                 ~30     !6
         48        BOOL_NOT                                         ~31     ~30
         49      > JMPZ                                                     ~31, ->52
   39    50    >   CONCAT                                           ~32     '%23', !6
         51        ASSIGN_OP                                     8          !4, ~32
   43    52    >   CONCAT                                           ~34     !1, !4
         53        ASSIGN                                                   !7, ~34
   45    54        INIT_FCALL                                               'var_dump'
         55        SEND_VAR                                                 !7
         56        DO_ICALL                                                 
   47    57      > RETURN                                                   !7
   49    58*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYr5MR%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.22 ms | 1400 KiB | 21 Q