3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html_string = <<<STR <p>paragraph <a>link</a> </p> <div class="myclass"> <div>something</div> <div style="mystyle">something</div> <b><a href="#">link</a></b> <b><a href="#" name="a name">link</a></b> <b style="color:red">bold</b> <img src="../path" alt="something" /> <img src="../path" alt="something" class="myclass" /> </div> STR; $dom = new DOMDocument; // init new DOMDocument $dom->loadHTML(mb_convert_encoding($html_string, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); $nodes = $xpath->query('//@*'); foreach ($nodes as $node) { if($node->nodeName != "src" && $node->nodeName != "href" && $node->nodeName != "alt") { $node->parentNode->removeAttribute($node->nodeName); } } echo $dom->saveHTML(); // output cleaned HTML
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in /in/Eomdi on line 22 <p>paragraph <a>link</a> <div> <div>something</div> <div>something</div> <b><a href="#">link</a></b> <b><a href="#">link</a></b> <b>bold</b> <img src="../path" alt="something"> <img src="../path" alt="something"> </div></p>

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:
109.7 ms | 406 KiB | 5 Q