3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $emptyValue = "null"; $trueValue = "ok"; $falseValue = "nok"; $trueArray = array(1,'1',true,'true','yes' ); $falseArray = array(0,'0',false,'false','no' ); function testdata($data) { global $trueArray, $falseArray, $emptyValue, $trueValue, $falseValue; if( in_array($data, $trueArray, true) ) { return $trueValue; } elseif( in_array($data, $falseArray, true) ) { return $falseValue; } else { return $emptyValue; } } var_dump(testdata(false)); var_dump(testdata(true)); var_dump(testdata('true')); var_dump(testdata('false')); var_dump(testdata('yes')); var_dump(testdata('no')); var_dump(testdata('')); var_dump(testdata(1)); var_dump(testdata(0));
based on 1Uqjr
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
string(3) "nok" string(2) "ok" string(2) "ok" string(3) "nok" string(2) "ok" string(3) "nok" string(4) "null" string(2) "ok" string(3) "nok"
Output for hhvm-3.10.0

Process exited with code 153.