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);

preferences:
52.84 ms | 402 KiB | 5 Q