3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/GE0Yu:5 Stack trace: #0 /in/GE0Yu(28): IsEqual(' 5', ' 5') #1 {main} thrown in /in/GE0Yu on line 5
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.98 ms | 401 KiB | 8 Q