3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = <<< EOT <?xml version='1.0' encoding='UTF-8'?> <eveapi version="2"> <currentTime>2013-10-01 18:00:01</currentTime> <result> <rowset name="members" key="characterID" columns="characterID, name"> <row characterID="2234" name="Bob"> <format type="test">Bob format</format> </row> <row characterID="555" name="John">test1 <format type="test">John format</format> </row> </rowset> </result> <cachedUntil>2013-10-01 18:57:01</cachedUntil> </eveapi> EOT; $simpleXML = simplexml_load_string($xml); // Load XML string data into the simplexml object parser foreach ($simpleXML->result->rowset as $rowset) { foreach ($rowset->row as $row) { $titles = []; echo "cp "; print_r($row->format); echo " cp "; $name = $row['name']->__toString(); foreach($row as $attrib){ if($attrib['name']->__toString() === 'titles'){ foreach($attrib as $title){ $titles[] = $title['titleName']->__toString(); } } } echo $name . ' : ' . implode(' - ', $titles) . "<br/>\n"; } }
Output for 7.0.0 - 7.1.0
cp SimpleXMLElement Object ( [@attributes] => Array ( [type] => test ) [0] => Bob format ) cp Fatal error: Uncaught Error: Call to a member function __toString() on null in /in/kVBMq:30 Stack trace: #0 {main} thrown in /in/kVBMq on line 30
Process exited with code 255.
Output for 5.6.0 - 5.6.28
cp SimpleXMLElement Object ( [@attributes] => Array ( [type] => test ) [0] => Bob format ) cp Fatal error: Call to a member function __toString() on null in /in/kVBMq on line 30
Process exited with code 255.
Output for 5.4.0 - 5.5.38
cp SimpleXMLElement Object ( [@attributes] => Array ( [type] => test ) [0] => Bob format ) cp Fatal error: Call to a member function __toString() on a non-object in /in/kVBMq on line 30
Process exited with code 255.
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/kVBMq on line 24
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected '[' in /in/kVBMq on line 25
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/kVBMq on line 24
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/kVBMq on line 24
Process exited with code 255.