3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr=['name'=>'test']; var_dump('abcdefg' == 0); // true var_dump('1abcdef' == 1); // true var_dump('2abcdef' == 2); // true function arrayToXml($arr) { $xml = "<xml>"; foreach ($arr as $key=>$val) { if (is_numeric($val)) { $xml.="<".$key.">".$val."</".$key.">"; } else $xml.="<".$key."><![CDATA[".$val."]]></".$key.">"; } $xml.="</xml>"; return $xml; } $nativeObj["AppId"] = 5; $nativeObj["Package"] = 'gfgf'; $nativeObj["TimeStamp"] = time(); $nativeObj["NonceStr"] = 43; $nativeObj["RetCode"] = 65; $nativeObj["RetErrMsg"] = 88; echo arrayToXml($nativeObj);
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
bool(true) bool(true) bool(true) <xml><AppId>5</AppId><Package><![CDATA[gfgf]]></Package><TimeStamp>1400760560</TimeStamp><NonceStr>43</NonceStr><RetCode>65</RetCode><RetErrMsg>88</RetErrMsg></xml>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/49WXM on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/49WXM on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/49WXM on line 2
Process exited with code 255.