3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $t = [1,2,3]; foreach($t as $k => $v) { } var_dump($v); die; $string = <<<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; $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 2LV7f
Output for 5.4.0 - 7.2.0
int(3)
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/onktP on line 2
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/onktP on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/onktP on line 2
Process exited with code 255.