3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php public function containsString($str, $cont = array()) { $arr = ( ! is_array($cont)) ? array($cont) : $cont; // turn the string into an array foreach ($arr as $char) { if (strstr($str, $char)) { return true; } } return false; } public function containsString_mlocati($str, $cont = array()) { $arr = is_array($cont)) ? $cont : array($cont); foreach($arr as $item) { if(strstr($str, $item) !== false) { return true; } } return false; } $cont = array('hi there', 'ciao', 'salut', 'Number of items: 0'); echo "Usually works:\n"; $str = 'not-existing'; var_dump(containsString($str, $cont)); var_dump(containsString_mlocati($str, $cont)); $str = 'hi'; var_dump(containsString($str, $cont)); var_dump(containsString_mlocati($str, $cont)); echo "\n\n"; echo "**BUT:\n"; $str = '0'; var_dump(containsString($str, $cont)); var_dump(containsString_mlocati($str, $cont));
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/cccJD on line 2
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_PUBLIC in /in/cccJD on line 2
Process exited with code 255.