3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = ' <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <body> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae ex a arcu tempus tincidunt ac non nulla. Aliquam erat volutpat. Mauris nunc ex, imperdi ▶ <figure class="image"> <img src="/storage/12/articles/pictures/body_1574785274232_0d61f8370cad1d412f80b84d143e1257.jpeg"/> <figcaption>caption zzzzz</figcaption> </figure> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae ex a arcu tempus tincidunt ac non nulla. Aliquam erat volutpat. Mauris nunc ex, imperdi ▶ <p>&#xA0;</p> </body> </html> '; $dom_err = libxml_use_internal_errors(true); $dom = new \DOMDocument('1.0', 'utf-8'); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED); $xpath = new \DOMXPath($dom); foreach ($xpath->query("//figure") as $img) { $p = $dom->createElement("p"); $p->setAttribute('style', 'text-align:center'); $img->parentNode->replaceChild($p, $img); $p->appendChild($img); } echo $dom->saveHTML();
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/e32JJ on line 20 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <?xml version="1.0" standalone="yes"?><html> <body> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae ex a arcu tempus tincidunt ac non nulla. Aliquam erat volutpat. Mauris nunc ex, imperdi &#9654; <p style="text-align:center"><figure class="image"> <img src="/storage/12/articles/pictures/body_1574785274232_0d61f8370cad1d412f80b84d143e1257.jpeg"> <figcaption>caption zzzzz</figcaption> </figure></p> </p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae ex a arcu tempus tincidunt ac non nulla. Aliquam erat volutpat. Mauris nunc ex, imperdi &#9654; </p><p>&nbsp;</p> </body> </html>

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:
37.03 ms | 409 KiB | 5 Q