3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $uri = 'http://www.w3.org/2001/XMLSchema-instance'; $root = new SimpleXMLElement('<root/>'); //$root->addAttribute('xmlns:i', $uri); $child = $root->addChild('foo'); $child->addAttribute('bar', 'baz', $uri); echo $root->asXml();
based on FCEFQ
Output for 5.2.6 - 7.2.0
Warning: SimpleXMLElement::addAttribute(): Attribute requires prefix for namespace in /in/bdHT1 on line 8 <?xml version="1.0"?> <root><foo/></root>
Output for 5.1.3 - 5.2.5
<?xml version="1.0"?> <root><foo xmlns="http://www.w3.org/2001/XMLSchema-instance" bar="baz"/></root>
Output for 5.0.0 - 5.1.2
Fatal error: Call to undefined method SimpleXMLElement::addChild() in /in/bdHT1 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/bdHT1 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/bdHT1 on line 4