3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html=<<<HTML <img src="/relative/url/img.jpg" /> <form action="/"> <a href='/relative/url/'>Note the Single Quote</a> <img src="//site.com/protocol-relative-img.jpg" /> HTML; $base='https://example.com'; echo preg_replace('~(?:src|action|href)=[\'"]\K/(?!/)[^\'"]*~',"$base$0",$html);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vtMu
function name:  (null)
number of ops:  11
compiled vars:  !0 = $html, !1 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cimg+src%3D%22%2Frelative%2Furl%2Fimg.jpg%22+%2F%3E%0A%3Cform+action%3D%22%2F%22%3E%0A%3Ca+href%3D%27%2Frelative%2Furl%2F%27%3ENote+the+Single+Quote%3C%2Fa%3E%0A%3Cimg+src%3D%22%2F%2Fsite.com%2Fprotocol-relative-img.jpg%22+%2F%3E'
    9     1        ASSIGN                                                   !1, 'https%3A%2F%2Fexample.com'
   11     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%7E%28%3F%3Asrc%7Caction%7Chref%29%3D%5B%27%22%5D%5CK%2F%28%3F%21%2F%29%5B%5E%27%22%5D%2A%7E'
          4        NOP                                                      
          5        FAST_CONCAT                                      ~4      !1, '%240'
          6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        ECHO                                                     $5
         10      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.55 ms | 1398 KiB | 15 Q