3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( 'egg' => true, 'cheese' => false, 'hair' => 765, 'goblins' => null, 'ogres' => 'no ogres allowed in this array' ); echo "// Loose checking\n\n"; // return values are in comments // First three make sense, last four do not echo (in_array(null, $array) ? 'true' : 'false')."\n"; // true echo (in_array(false, $array) ? 'true' : 'false')."\n"; // true echo (in_array(765, $array) ? 'true' : 'false')."\n"; // true echo (in_array(763, $array) ? 'true' : 'false')."\n"; // true echo (in_array('egg', $array) ? 'true' : 'false')."\n"; // true echo (in_array('hhh', $array) ? 'true' : 'false')."\n"; // true echo (in_array(array(), $array) ? 'true' : 'false')."\n"; // true echo "\n\n// Strict checking\n\n"; echo (in_array(null, $array, true) ? 'true' : 'false')."\n"; // true echo (in_array(false, $array, true) ? 'true' : 'false')."\n"; // true echo (in_array(765, $array, true) ? 'true' : 'false')."\n"; // true echo (in_array(763, $array, true) ? 'true' : 'false')."\n"; // false echo (in_array('egg', $array, true) ? 'true' : 'false')."\n"; // false echo (in_array('hhh', $array, true) ? 'true' : 'false')."\n"; // false echo (in_array(array(), $array, true) ? 'true' : 'false')."\n"; // false
Output for 4.3.0 - 5.0.5, 5.1.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
// Loose checking true true true true true true true // Strict checking true true true false false false false
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/7n1li on line 31
Process exited with code 255.