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) { var_dump($baseUrl); exit(); var_dump($matches); return ''; $srcTag = $matches[0]; $url = $matches[1]; $url = str_replace('../', '', $url); $url = str_replace('./', '', $url); $url = str_replace('../', '', $url); }; preg_replace_callback($pattern, $callback, $source);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nDmVU
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%2FnDmVU%3A16%240'
          4        BIND_LEXICAL                                             ~7, !2
          5        ASSIGN                                                   !3, ~7
   37     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%2FnDmVU%3A16%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/nDmVU
function name:  {closure}
number of ops:  33
compiled vars:  !0 = $matches, !1 = $baseUrl, !2 = $srcTag, !3 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   19     2        INIT_FCALL                                               'var_dump'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                                 
          5      > EXIT                                                     
   22     6*       INIT_FCALL                                               'var_dump'
          7*       SEND_VAR                                                 !0
          8*       DO_ICALL                                                 
   23     9*       RETURN                                                   ''
   26    10*       FETCH_DIM_R                                      ~6      !0, 0
         11*       ASSIGN                                                   !2, ~6
   27    12*       FETCH_DIM_R                                      ~8      !0, 1
         13*       ASSIGN                                                   !3, ~8
   29    14*       INIT_FCALL                                               'str_replace'
         15*       SEND_VAL                                                 '..%2F'
         16*       SEND_VAL                                                 ''
         17*       SEND_VAR                                                 !3
         18*       DO_ICALL                                         $10     
         19*       ASSIGN                                                   !3, $10
   30    20*       INIT_FCALL                                               'str_replace'
         21*       SEND_VAL                                                 '.%2F'
         22*       SEND_VAL                                                 ''
         23*       SEND_VAR                                                 !3
         24*       DO_ICALL                                         $12     
         25*       ASSIGN                                                   !3, $12
   31    26*       INIT_FCALL                                               'str_replace'
         27*       SEND_VAL                                                 '..%2F'
         28*       SEND_VAL                                                 ''
         29*       SEND_VAR                                                 !3
         30*       DO_ICALL                                         $14     
         31*       ASSIGN                                                   !3, $14
   34    32*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.68 ms | 1400 KiB | 19 Q