3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <img src="docs/relative/url/img.jpg" /> <img src="/docs/relative/url/img.jpg" /> <img src="https://docs/relative/url/img.jpg" /> <img src="http://docs/relative/url/img.jpg" /> HTML; $base = 'https://example.com/'; echo preg_replace( '~ src="(?!http)\K/?~', $base, $html );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/msYZM
function name:  (null)
number of ops:  9
compiled vars:  !0 = $html, !1 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cimg+src%3D%22docs%2Frelative%2Furl%2Fimg.jpg%22+%2F%3E%0A%3Cimg+src%3D%22%2Fdocs%2Frelative%2Furl%2Fimg.jpg%22+%2F%3E%0A%3Cimg+src%3D%22https%3A%2F%2Fdocs%2Frelative%2Furl%2Fimg.jpg%22+%2F%3E%0A%3Cimg+src%3D%22http%3A%2F%2Fdocs%2Frelative%2Furl%2Fimg.jpg%22+%2F%3E'
    9     1        ASSIGN                                                   !1, 'https%3A%2F%2Fexample.com%2F'
   11     2        INIT_FCALL                                               'preg_replace'
   12     3        SEND_VAL                                                 '%7E+src%3D%22%28%3F%21http%29%5CK%2F%3F%7E'
   13     4        SEND_VAR                                                 !1
   14     5        SEND_VAR                                                 !0
   11     6        DO_ICALL                                         $4      
   14     7        ECHO                                                     $4
   15     8      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.56 ms | 996 KiB | 14 Q