3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <img src="icons/example.svg"> <a href="http://www.example.com">a link</a> <link href="css/example.css"> <iframe src="http://www.example.com/default.htm"></iframe> </div> HTML; $doc = new DOMDocument(); $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $dom->substituteEntities = false; $xpath = new DOMXPath($doc); foreach ($xpath->query('//img/@src | //link/@href') as $attr) { $attr->value = "{{asset('" . $attr->value . ")'}}"; } echo $doc->saveHTML();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
Fatal error: Uncaught Error: Attempt to assign property "substituteEntities" on null in /in/ZHSFX:13 Stack trace: #0 {main} thrown in /in/ZHSFX on line 13
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Attempt to assign property "substituteEntities" on null in /in/ZHSFX:13 Stack trace: #0 {main} thrown in /in/ZHSFX on line 13
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Creating default object from empty value in /in/ZHSFX on line 13 <div> <img src="%7B%7Basset('icons/example.svg)'%7D%7D"> <a href="http://www.example.com">a link</a> <link href="%7B%7Basset('css/example.css)'%7D%7D"> <iframe src="http://www.example.com/default.htm"></iframe> </div>

preferences:
163.15 ms | 403 KiB | 182 Q