3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $html = new DOMDocument('1.0', 'iso-8859-1'); $ul = new DomElement('ul'); $html->appendChild($ul); $friends = [ ['firstname' => 'A', 'lastname' => '1',], ['firstname' => 'B', 'lastname' => '2',], ['firstname' => 'C', 'lastname' => '3',], ]; foreach ($friends as $person) { $li = new DomElement('li', $person['firstname'] . ',' . $person['lastname']); $li->setAttribute('class', 'personLi'); $ul->appendChild($li); } echo $html->saveXML();
based on P54AT
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught DOMException: No Modification Allowed Error in /in/Kr55t:16 Stack trace: #0 /in/Kr55t(16): DOMElement->setAttribute('class', 'personLi') #1 {main} thrown in /in/Kr55t on line 16
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Fatal error: Uncaught exception 'DOMException' with message 'No Modification Allowed Error' in /in/Kr55t:16 Stack trace: #0 /in/Kr55t(16): DOMElement->setAttribute('class', 'personLi') #1 {main} thrown in /in/Kr55t on line 16
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Kr55t on line 8
Process exited with code 255.