3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = "<root><first/><second/><third/></root>"; $xml = simplexml_load_string($xml); foreach ($xml->children() as $tag => $el) { var_dump($tag, $el); var_dump($xml->$tag == $el); }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
string(5) "first" object(SimpleXMLElement)#4 (0) { } bool(false) string(6) "second" object(SimpleXMLElement)#5 (0) { } bool(false) string(5) "third" object(SimpleXMLElement)#4 (0) { } bool(false)

preferences:
61.28 ms | 406 KiB | 5 Q