3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <div class="content"> <h2>Hello World</h2> <p>This is a paragraph.</p> <button />test</button> </div> HTML; libxml_use_internal_errors(true); $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); libxml_clear_errors(); // Change the heading text $h2 = $dom->getElementsByTagName('h2')->item(0); $h2->nodeValue = 'Updated Heading'; // Add a class to the paragraph $p = $dom->getElementsByTagName('p')->item(0); $p->setAttribute('class', 'intro'); // Output the modified HTML echo $dom->saveHTML();
Output for git.master, git.master_jit
<div class="content"> <h2>Updated Heading</h2> <p class="intro">This is a paragraph.</p> <button></button>test </div>

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:
51.31 ms | 786 KiB | 4 Q