3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This demos a (possible) bug in PHP, which is observed in PHP 5.6, 7.2, 7.3, 7.4 and 8.0 (not tested on 8.1) * * Access behaviour of a SimpleXMLElement changes if that node has a sibling. * * In this example, adding 'fiz' to 'foo' (which is the outer node) will change behaviour when accessing 'bar' (an inner node) */ $xml_1 = new SimpleXMLElement('<foo><bar><baz/></bar></foo>'); print_r($xml_1); // As expected print_r($xml_1->bar); // As expected, $bar contains property $baz, which is an empty SimpleXMLElement $xml_2 = new SimpleXMLElement('<foo><bar><baz/></bar><fiz/></foo>'); print_r($xml_2); // As expected, property $bar is equal to that observed in print_r($xml_1) print_r($xml_2->bar); // UNEXPECTED: property $bar is an array, containing one SimpleXMLElement with property $baz which is an empty SimpleXMLElement
Output for git.master, git.master_jit, rfc.property-hooks
SimpleXMLElement Object ( [bar] => SimpleXMLElement Object ( [baz] => SimpleXMLElement Object ( ) ) ) SimpleXMLElement Object ( [baz] => SimpleXMLElement Object ( ) ) SimpleXMLElement Object ( [bar] => SimpleXMLElement Object ( [baz] => SimpleXMLElement Object ( ) ) [fiz] => SimpleXMLElement Object ( ) ) SimpleXMLElement Object ( [0] => SimpleXMLElement Object ( [baz] => SimpleXMLElement Object ( ) ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
104.06 ms | 1468 KiB | 4 Q