3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function hash($item) { if (is_object($item)) { return spl_object_hash($item); } elseif (is_numeric($item) || is_bool($item)) { return "s_" . intval($item); } elseif (is_scalar($item)) { return "s_$item"; } elseif (is_resource($item)) { return "r_$item"; } elseif (is_array($item)) { return 'a_' . md5(serialize($item)); } return '0'; } var_dump(hash(1)); var_dump(hash(1.0)); var_dump(hash("1")); var_dump(hash("1.0")); var_dump(hash(true)); var_dump(hash(0)); var_dump(hash(0.0)); var_dump(hash("0")); var_dump(hash("0.0")); var_dump(hash(false));
based on 46bPX
Output for 5.1.2 - 5.4.35
Fatal error: Cannot redeclare hash() in /in/FL8dP on line 17
Process exited with code 255.
Output for 4.3.0 - 5.1.1
string(3) "s_1" string(3) "s_1" string(3) "s_1" string(3) "s_1" string(3) "s_1" string(3) "s_0" string(3) "s_0" string(3) "s_0" string(3) "s_0" string(3) "s_0"