3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = simplexml_load_string('<root/>'); $node = $xml->NOT_EXISTING_NODE_NAME; var_dump($node instanceof \SimpleXMLElement); var_dump($node->asXML()); var_dump($node->count()); var_dump($node->getName()); echo "\nattributes:\n"; $node2 = $node->attributes(); var_dump($node2 instanceof \SimpleXMLElement); var_dump($node2->asXML()); var_dump($node2->count()); var_dump($node2->getName()); echo "\nchildren:\n"; $node3 = $node->children(); var_dump($node3 instanceof \SimpleXMLElement); var_dump($node3->asXML()); var_dump($node3->count()); var_dump($node3->getName());
Output for 8.0.0 - 8.0.13, 8.1rc1 - rc3
bool(true) bool(false) int(0) string(0) "" attributes: bool(false) Fatal error: Uncaught Error: Call to a member function asXML() on null in /in/1BHKS:13 Stack trace: #0 {main} thrown in /in/1BHKS on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.26
bool(true) bool(false) int(0) string(0) "" attributes: bool(true) Warning: SimpleXMLElement::asXML(): Node no longer exists in /in/1BHKS on line 13 Warning: SimpleXMLElement::asXML(): Node no longer exists in /in/1BHKS on line 13 bool(false) Warning: SimpleXMLElement::count(): Node no longer exists in /in/1BHKS on line 14 int(0) Warning: SimpleXMLElement::getName(): Node no longer exists in /in/1BHKS on line 15 Warning: SimpleXMLElement::getName(): Node no longer exists in /in/1BHKS on line 15 string(0) "" children: bool(true) Warning: SimpleXMLElement::asXML(): Node no longer exists in /in/1BHKS on line 20 Warning: SimpleXMLElement::asXML(): Node no longer exists in /in/1BHKS on line 20 bool(false) Warning: SimpleXMLElement::count(): Node no longer exists in /in/1BHKS on line 21 int(0) Warning: SimpleXMLElement::getName(): Node no longer exists in /in/1BHKS on line 22 Warning: SimpleXMLElement::getName(): Node no longer exists in /in/1BHKS on line 22 string(0) ""
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1BHKS on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1BHKS on line 12 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1BHKS on line 19 bool(true) bool(false) Fatal error: Call to undefined method SimpleXMLElement::count() in /in/1BHKS on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/1BHKS on line 5
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_STRING in /in/1BHKS on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1BHKS on line 5
Process exited with code 255.

preferences:
50.1 ms | 467 KiB | 5 Q