3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = new SimpleXMLElement('<design />'); // set parent node $xml->addAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xml->addAttribute('xmlns', 'http://anydomain.com'); // attributes $xml->addChild('name', 'xxx'); // add those children $xml->addChild('description', 'yyy'); echo $xml->asXML(); // output
Output for 5.1.3 - 7.1.0
<?xml version="1.0"?> <design xlink="http://www.w3.org/1999/xlink" xmlns="http://anydomain.com"><name>xxx</name><description>yyy</description></design>
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.2
Fatal error: Call to undefined method SimpleXMLElement::addAttribute() in /in/eX7Ik on line 3
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/eX7Ik on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/eX7Ik on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/eX7Ik on line 2