3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = simplexml_load_string("<xml>test</xml>"); if ($xml) { echo '$xml evaluates to true'; } else { echo '$xml evaluates to false, wtf!?'; } echo "\n\n"; var_dump($xml); echo "\n\n"; $xml = simplexml_load_string("<xml><test></test></xml>"); if ($xml) { echo '$xml evaluates to true'; } else { echo '$xml evaluates to false, wtf!?'; } echo "\n\n"; var_dump($xml); echo "\n\n";
based on rtNEm
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
$xml evaluates to true object(SimpleXMLElement)#1 (1) { [0]=> string(4) "test" } $xml evaluates to true object(SimpleXMLElement)#2 (1) { ["test"]=> object(SimpleXMLElement)#1 (0) { } }
Output for hhvm-3.18.5 - 3.22.0
$xml evaluates to true object(SimpleXMLElement)#1 (1) { [0]=> string(4) "test" } $xml evaluates to true object(SimpleXMLElement)#2 (1) { ["test"]=> object(SimpleXMLElement)#3 (0) { } }