3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if(!class_exists('SimpleXMLElement')) die("Bonkers"); $xml = new SimpleXMLElement('<xml xmlns:abstract="urn:my.org:abstract"><abstract:node>foo</abstract: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 7.0.14 - 7.1.0
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(false) bool(true) bool(false) int(0) Warning: count(): Node no longer exists in /in/DjhdJ on line 11 int(0) ---------------------- string(4) "NULL" bool(false) bool(true) bool(true) int(0) Fatal error: Uncaught Error: Call to a member function children() on null in /in/DjhdJ:18 Stack trace: #0 {main} thrown in /in/DjhdJ on line 18
Process exited with code 255.
Output for 7.0.0 - 7.0.10
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(0) Warning: count(): Node no longer exists in /in/DjhdJ on line 11 int(0) ---------------------- string(4) "NULL" bool(false) bool(true) bool(true) int(0) Fatal error: Uncaught Error: Call to a member function children() on null in /in/DjhdJ:18 Stack trace: #0 {main} thrown in /in/DjhdJ on line 18
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(0) int(0) ---------------------- string(4) "NULL" bool(false) bool(true) bool(true) int(0) Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function children() on a non-object (null)' in /in/DjhdJ:18 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.28
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(0) Warning: count(): Node no longer exists in /in/DjhdJ on line 11 int(0) ---------------------- string(4) "NULL" bool(false) bool(true) bool(true) int(0) Fatal error: Call to a member function children() on null in /in/DjhdJ on line 18
Process exited with code 255.
Output for 5.1.2 - 5.5.38
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(0) Warning: count(): Node no longer exists in /in/DjhdJ on line 11 int(0) ---------------------- string(4) "NULL" bool(false) bool(true) bool(true) int(0) Fatal error: Call to a member function children() on a non-object in /in/DjhdJ on line 18
Process exited with code 255.
Output for 5.0.0 - 5.1.1
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(1) int(1) ---------------------- string(4) "NULL" bool(false) bool(true) bool(true) int(0) Fatal error: Call to a member function children() on a non-object in /in/DjhdJ on line 18
Process exited with code 255.
Output for 4.3.0 - 4.4.9
Bonkers