3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if(!class_exists('SimpleXMLElement')) die("Bonkers"); $xml = new SimpleXMLElement('<xml><node>foo</node></xml>'); var_dump($xml->node); var_dump(gettype($xml->node)); var_dump(isset($xml->node)); var_dump(empty($xml->node)); var_dump(is_null($xml->node)); var_dump(count($xml->node)); var_dump(count($xml->node->children())); echo "----------------------\n"; var_dump(gettype($xml->node->foo)); var_dump(isset($xml->node->foo)); var_dump(empty($xml->node->foo)); var_dump(is_null($xml->node->foo)); var_dump(count($xml->node->foo)); var_dump(count($xml->node->foo->children()));
Output for 5.1.2 - 5.6.28, 7.0.0 - 7.1.0
object(SimpleXMLElement)#2 (1) { [0]=> string(3) "foo" } string(6) "object" bool(true) bool(false) bool(false) int(1) int(0) ---------------------- string(6) "object" bool(false) bool(true) bool(false) int(0) Warning: count(): Node no longer exists in /in/S8pvV on line 18 int(0)
Output for hhvm-3.12.0
object(SimpleXMLElement)#2 (1) { [0]=> string(3) "foo" } string(6) "object" bool(true) bool(false) bool(false) int(1) int(0) ---------------------- string(6) "object" bool(false) bool(true) bool(false) int(0) int(0)
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.1.1
object(SimpleXMLElement)#2 (1) { [0]=> string(3) "foo" } string(6) "object" bool(true) bool(false) bool(false) int(1) int(1) ---------------------- string(6) "object" bool(false) bool(true) bool(false) int(1) int(1)
Output for 4.3.0 - 4.4.9
Bonkers