3v4l.org

run code in 500+ PHP versions simultaneously
<?php $content = <<<DATA <body> <img src="not-this-one.jpg" alt="unique"/> <div id="1"> <img src="this-one.jpg" alt="som title"/> <img src="this-one-no-alt.jpg"/> </div> </body> DATA; $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $images = $xpath->query('//div/img'); $focuskw = "NEWVALUE"; foreach ($dom->getElementsByTagName('div') as $div) { foreach ($div->getElementsByTagName('img') as $img) { $img->setAttribute('alt', 'http://google.com/'); } } $content = $dom->saveHTML(); print_r($content);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $xpath in /in/Yjm0s on line 16 Fatal error: Uncaught Error: Call to a member function query() on null in /in/Yjm0s:16 Stack trace: #0 {main} thrown in /in/Yjm0s on line 16
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.66 ms | 1498 KiB | 4 Q