3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!DOCTYPE html> <title>Valid HTML5 Document</title> <p>Paragraph 1</p> <script>console.log("</html>Console log text");</script> <p>Paragraph 2</p>'; // DOM/HTMLDocument (lexbor) $newDom = \DOM\HTMLDocument::createFromString($html); $paragraphs = $newDom->getElementsByTagName('p'); echo "\n"; echo "DOM\HTMLDocument parsing (lexbor)\n"; echo "---------------------------------\n"; echo "{$paragraphs->length} paragraph elements found.\n"; // 2 paragraphs found (correct) foreach ($paragraphs as $p) { echo " * " . trim($p->textContent) . "\n"; } echo "\n"; echo "DOM serialised:\n"; echo $newDom->saveHtml();
Output for git.master_jit, git.master
DOM\HTMLDocument parsing (lexbor) --------------------------------- 2 paragraph elements found. * Paragraph 1 * Paragraph 2 DOM serialised: <!DOCTYPE html><html><head><title>Valid HTML5 Document</title> </head><body><p>Paragraph 1</p> <script>console.log("</html>Console log text");</script> <p>Paragraph 2</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:
26.06 ms | 406 KiB | 5 Q