3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'https://roger.shopery.dev/admin/'; $hostName = 'gros.cat'; $pattern = '~(http)(s?)://([a-zA-Z0\.-9]+)([:0-9]+)?/(.*)~U'; preg_match($pattern, $url, $matches); var_dump( $matches ); var_dump( preg_replace( $pattern, "$1//$hostName$4/", $url ));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/frNNJ
function name:  (null)
number of ops:  23
compiled vars:  !0 = $url, !1 = $hostName, !2 = $pattern, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'https%3A%2F%2Froger.shopery.dev%2Fadmin%2F'
    4     1        ASSIGN                                                   !1, 'gros.cat'
    6     2        ASSIGN                                                   !2, '%7E%28http%29%28s%3F%29%3A%2F%2F%28%5Ba-zA-Z0%5C.-9%5D%2B%29%28%5B%3A0-9%5D%2B%29%3F%2F%28.%2A%29%7EU'
    7     3        INIT_FCALL                                               'preg_match'
          4        SEND_VAR                                                 !2
          5        SEND_VAR                                                 !0
          6        SEND_REF                                                 !3
          7        DO_ICALL                                                 
    8     8        INIT_FCALL                                               'var_dump'
    9     9        SEND_VAR                                                 !3
         10        DO_ICALL                                                 
   12    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'preg_replace'
   13    13        SEND_VAR                                                 !2
   14    14        ROPE_INIT                                     3  ~10     '%241%2F%2F'
         15        ROPE_ADD                                      1  ~10     ~10, !1
         16        ROPE_END                                      2  ~9      ~10, '%244%2F'
         17        SEND_VAL                                                 ~9
   15    18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $12     
         20        SEND_VAR                                                 $12
         21        DO_ICALL                                                 
   16    22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.08 ms | 1395 KiB | 19 Q