3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function IsEqual( $str,$str2 ) { $res = 0; for ($i=0, $max = count($str) -1; $i < $max; $i++) { if ( $str[$i] == $str2[$i]) { $res++; } else if ($str[$i] != $str2[$i]) { $res = 0; break; } } if (!$res) { return strlen($str) - strlen($str2); } else { return $res; } } $str = " 5"; $str2 = " 5"; $compRes = IsEqual($str,$str2); if (!$compRes){ echo "The \$str and \$str2 are the same.\n"; } else { echo "\$str is ",($compRes == 1)? "greater " : "less ", " than \$str2"; }
Output for 7.2.0 - 7.2.6
Warning: count(): Parameter must be an array or an object that implements Countable in /in/GE0Yu on line 5 $str is less than $str2
Output for 4.3.0 - 7.1.20
$str is less than $str2