3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = new SimpleXMLElement('<foo bar="baz"></foo>'); function iterator(SimpleXMLElement $xml): iterable { foreach ($xml->children() as $img) { yield $img["src"] ?? ""; } } iterator_to_array(iterator($xml->bar));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: foreach() argument must be of type array|object, null given in /in/rqvMc on line 6
Output for 7.4.0 - 7.4.33
Warning: iterator(): Node no longer exists in /in/rqvMc on line 6

preferences:
138.22 ms | 401 KiB | 121 Q