3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <div id='makeme' class='testme'> <span id='whatspanID'>somthing</span> <p class='ptagclass'></p> </div> HTML; $dom = new DOMDocument(); $dom->loadHtml($html); $xpath = new DOMXpath($dom); $div = $xpath->evaluate('//div[@id="makeme"]')->item(0); $nodes = $xpath->evaluate('.//*/@*{not(local-name() = "id")}', $div); $length = count($nodes); for($i = $length - 1; $i >= 0; --$i) { $node = $nodes->item($i); var_dump($node); $node->parentNode->removeChild($node); } echo $dom->saveHtml($div);
Output for git.master, git.master_jit
Warning: DOMXPath::evaluate(): Invalid expression in /in/JA7PO on line 15 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /in/JA7PO:16 Stack trace: #0 {main} thrown in /in/JA7PO on line 16
Process exited with code 255.
Output for rfc.property-hooks
Warning: DOMXPath::evaluate(): Invalid expression in /in/JA7PO on line 15 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, false given in /in/JA7PO:16 Stack trace: #0 {main} thrown in /in/JA7PO 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:
56.7 ms | 401 KiB | 8 Q