3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!doctype html> <html> <body> <img src="computerIcon.png"> </body> </html> '; $proxy = 'https://proxy.example.com/?url=https://domain.example.com/'; $xml = new DOMDocument("1.0", "utf-8"); $xml->loadHTML($html); foreach($xml->getElementsByTagName('img') as $item) { $item->setAttribute('src', $proxy . $item->getAttribute('src')); } $xml->formatOutput = true; echo $xml->saveHTML();
Output for 8.0.30, 8.1.22 - 8.1.33, 8.2.9 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
<!DOCTYPE html> <html> <body> <img src="https://proxy.example.com/?url=https://domain.example.com/computerIcon.png"> </body> </html>
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.29, 8.1.0 - 8.1.21, 8.2.0 - 8.2.8
<!DOCTYPE html> <html><body> <img src="https://proxy.example.com/?url=https://domain.example.com/computerIcon.png"> </body></html>

preferences:
142.29 ms | 408 KiB | 5 Q