3v4l.org

run code in 300+ PHP versions simultaneously
<?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->children('abstract',true)->node)); var_dump(isset($xml->children('abstract',true)->node)); var_dump(empty($xml->children('abstract',true)->node)); var_dump(is_null($xml->children('abstract',true)->node)); var_dump(count($xml->children('abstract',true)->node)); var_dump(count($xml->children('abstract',true)->node->children()));
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(false) bool(true) bool(false) int(0) Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /in/j3v7h:11 Stack trace: #0 {main} thrown in /in/j3v7h on line 11
Process exited with code 255.
Output for 8.0.0 - 8.0.9
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(false) bool(true) bool(false) int(0) Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in /in/j3v7h:11 Stack trace: #0 {main} thrown in /in/j3v7h on line 11
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(false) bool(true) bool(false) int(0) Warning: main(): Node no longer exists in /in/j3v7h on line 11 int(0) ---------------------- string(6) "object" bool(true) bool(false) bool(false) int(1) int(0)
Output for 7.0.14 - 7.0.20, 7.1.0 - 7.1.33
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(false) bool(true) bool(false) int(0) Warning: count(): Node no longer exists in /in/j3v7h on line 11 int(0) ---------------------- string(6) "object" bool(true) bool(false) bool(false) int(1) int(0)
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 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/j3v7h on line 11 int(0) ---------------------- string(6) "object" bool(true) bool(false) bool(false) int(1) int(0)
Output for 5.1.2 - 5.1.6
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(0) Warning: count(): Node no longer exists in /in/j3v7h on line 11 int(0) ---------------------- Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 13 Notice: Trying to get property of non-object in /in/j3v7h on line 13 string(4) "NULL" Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 14 bool(false) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 15 bool(true) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 16 Notice: Trying to get property of non-object in /in/j3v7h on line 16 bool(true) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 17 Notice: Trying to get property of non-object in /in/j3v7h on line 17 int(0) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 18 Notice: Trying to get property of non-object in /in/j3v7h on line 18 Fatal error: Call to a member function children() on a non-object in /in/j3v7h on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
object(SimpleXMLElement)#2 (0) { } string(6) "object" bool(true) bool(false) bool(false) int(1) int(1) ---------------------- Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 13 Notice: Trying to get property of non-object in /in/j3v7h on line 13 string(4) "NULL" Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 14 bool(false) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 15 bool(true) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 16 Notice: Trying to get property of non-object in /in/j3v7h on line 16 bool(true) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 17 Notice: Trying to get property of non-object in /in/j3v7h on line 17 int(0) Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /in/j3v7h on line 18 Notice: Trying to get property of non-object in /in/j3v7h on line 18 Fatal error: Call to a member function children() on a non-object in /in/j3v7h on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/j3v7h on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/j3v7h on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/j3v7h on line 13
Process exited with code 255.

preferences:
236.77 ms | 401 KiB | 400 Q