3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php var_dump([(boolean) 'true', (boolean) 23]);die; $source = <<<XML <?xml version="1.0" encoding="UTF-8"?> <datapacket packet_type="send_data" version="3.15.3.15" level="1" reg_number="705" ogrn="1027808757899" mac_address="50:46:5D:4E:F7:06" comp_name="k415-1" interval_end_date="2015-03-26 14:12:53"> <teachers> <teacher teacher_id="705000000208" fio="Яловенко Любовь Николаевна" uid=""/> <teacher teacher_id="705000000211" fio="Шкарубо Людмила Ивановна" uid=""/> <teacher teacher_id="705000000214" fio="Шибаева Оксана Викторовна" uid=""/> <teacher_delete teacher_id="705000000214" fio="Шибаева Оксана Викторовна" uid=""/> <teacher_delete teacher_id="705000000214" fio="Шибаева Оксана Викторовна" uid=""/> </teachers> <last_marks> <last_mark last_mark_id="705000111240"/> <last_mark last_mark_id="705000111240"/> <last_mark_deleted last_mark_id="705000111240"/> <last_mark_deleted last_mark_id="705000144740"/> <last_mark_deleted last_mark_id="705000200530"/> </last_marks> </datapacket> XML; $reader = new XMLReader(); if ($reader->xml($source)) { var_dump($reader->readString());die; } else { throw new Exeption('Ошибка при разборе XML'); } // LIBXML_ERR_ERROR // LIBXML_ERR_FATAL // LIBXML_ERR_NONE // LIBXML_ERR_WARNING var_dump($xml); die; $xml = simplexml_load_string($string); foreach($xml->children()->children() as $nodeName => $child) { var_dump($child); $child = $child->attributes(); var_dump($child); $child = $child['@attributes']; var_dump($child); die; } die; $xml = new SimpleXMLElement($string); $result = $xml->xpath('teachers'); var_dump($result); die; while(list( , $node) = each($result)) { echo '/teachers: ',$node,"\n"; } /* Относительные пути также работают... */ $result = $xml->xpath('b/c'); while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n"; } ?>
based on DVlHc
Output for 5.4.2 - 7.3.0rc4
array(2) { [0]=> bool(true) [1]=> bool(true) }
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/5O0Jb on line 2
Process exited with code 255.