3v4l.org

run code in 300+ PHP versions simultaneously
<?php function url_replace($url, $component, callable $callback) { $map = [ PHP_URL_SCHEME => 2, PHP_URL_HOST => 4, PHP_URL_PATH => 5, PHP_URL_QUERY => 7, PHP_URL_FRAGMENT => 9, ]; if (!array_key_exists($component, $map)) { return $url; } $index = $map[$component]; if (preg_match('~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?~', $url, $matches, PREG_OFFSET_CAPTURE) && isset($matches[$index])) { $tmp = call_user_func($callback, $matches[$index][0]); return substr_replace($url, $tmp, $matches[$index][1], strlen($matches[$index][0])); } return $url; } $url = 'sip:foo@example.com'; echo url_replace($url, PHP_URL_PATH, function($path) { return 'bar@example.com'; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dJIGc
function name:  (null)
number of ops:  9
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, 'sip%3Afoo%40example.com'
   27     1        INIT_FCALL                                               'url_replace'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 5
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdJIGc%3A27%240'
   29     5        SEND_VAL                                                 ~2
          6        DO_FCALL                                      0  $3      
          7        ECHO                                                     $3
          8      > RETURN                                                   1

Function url_replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 38
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/dJIGc
function name:  url_replace
number of ops:  40
compiled vars:  !0 = $url, !1 = $component, !2 = $callback, !3 = $map, !4 = $index, !5 = $matches, !6 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        ASSIGN                                                   !3, <array>
   13     4        ARRAY_KEY_EXISTS                                 ~8      !1, !3
          5        BOOL_NOT                                         ~9      ~8
          6      > JMPZ                                                     ~9, ->8
   14     7    > > RETURN                                                   !0
   16     8    >   FETCH_DIM_R                                      ~10     !3, !1
          9        ASSIGN                                                   !4, ~10
   18    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%7E%5E%28%28%5B%5E%3A%2F%3F%23%5D%2B%29%3A%29%3F%28%2F%2F%28%5B%5E%2F%3F%23%5D%2A%29%29%3F%28%5B%5E%3F%23%5D%2A%29%28%5C%3F%28%5B%5E%23%5D%2A%29%29%3F%28%23%28.%2A%29%29%3F%7E'
         12        SEND_VAR                                                 !0
         13        SEND_REF                                                 !5
         14        SEND_VAL                                                 256
         15        DO_ICALL                                         $12     
         16      > JMPZ_EX                                          ~13     $12, ->19
         17    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !5, !4
         18        BOOL                                             ~13     ~14
         19    > > JMPZ                                                     ~13, ->38
   19    20    >   INIT_USER_CALL                                1          'call_user_func', !2
         21        FETCH_DIM_R                                      ~15     !5, !4
         22        FETCH_DIM_R                                      ~16     ~15, 0
         23        SEND_USER                                                ~16
         24        DO_FCALL                                      0  $17     
         25        ASSIGN                                                   !6, $17
   20    26        INIT_FCALL                                               'substr_replace'
         27        SEND_VAR                                                 !0
         28        SEND_VAR                                                 !6
         29        FETCH_DIM_R                                      ~19     !5, !4
         30        FETCH_DIM_R                                      ~20     ~19, 1
         31        SEND_VAL                                                 ~20
         32        FETCH_DIM_R                                      ~21     !5, !4
         33        FETCH_DIM_R                                      ~22     ~21, 0
         34        STRLEN                                           ~23     ~22
         35        SEND_VAL                                                 ~23
         36        DO_ICALL                                         $24     
         37      > RETURN                                                   $24
   22    38    > > RETURN                                                   !0
   23    39*     > RETURN                                                   null

End of function url_replace

Function %00%7Bclosure%7D%2Fin%2FdJIGc%3A27%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dJIGc
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1      > RETURN                                                   'bar%40example.com'
   29     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdJIGc%3A27%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.51 ms | 1403 KiB | 18 Q