3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class XMLCreator { private $data = Array ( "zipcode" => "95610", "city" => "Citrus Heights", "icao" => "KMCC", "ccobst" => "McClellan Airfield", "obdist" => 7.3067011821565, "oblat" => 38.667, "oblong" => -121.4, ); function __construct() { $this->generate_xml_element(); } function __destruct() { } function generate_xml_element() { $doc = new DOMDocument(); // we want a nice output $doc->formatOutput = true; $root = $doc->createElement('address'); $root = $doc->appendChild($root); foreach ($this->data as $key => $value) { $title = $doc->createElement($key); $title = $root->appendChild($title); $text = $doc->createTextNode($value); $text = $title->appendChild($text); } echo "Saving all the document:\n"; echo $doc->saveXML() . "\n"; } } ?>
Output for 5.0.0 - 7.1.0
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/W49VC on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/W49VC on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/W49VC on line 4
Process exited with code 255.