3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_palindrome($str) { $len = strlen($str); if ($len < 2) { // strings of 0 or 1 characters are palindromes return true; } elseif ($str[0] != $str[$len-1]) { // first character doesn't match last character, so not a palindrome return false; } else { // first character is equal to last character, // so see if the rest of the string is a palindrome return is_palindrome(substr($str, 1, $len - 2)); } } foreach (['rotor', 'a', 'deed', 'hello', 'xyyz'] as $str) { echo "\"$str\" is" . (is_palindrome($str) ? "" : " not") . " a palindrome\n"; } function is_palindrome_broken($str) { $len = strlen($str); if ($len < 2) { // strings of 0 or 1 characters are palindromes return true; } elseif ($str[0] != $str[$len-1]) { // first character doesn't match last character, so not a palindrome return false; } else { // first character is equal to last character, // so see if the rest of the string is a palindrome is_palindrome_broken(substr($str, 1, $len - 2)); } } foreach (['rotor', 'a', 'deed', 'hello', 'xyyz'] as $str) { echo "\"$str\" is" . (is_palindrome_broken($str) ? "" : " not") . " a palindrome\n"; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0130.00716.63
8.3.50.0090.00620.03
8.3.40.0100.00321.71
8.3.30.0110.00719.07
8.3.20.0080.00024.18
8.3.10.0000.00724.66
8.3.00.0070.00026.16
8.2.180.0040.01125.92
8.2.170.0110.00418.96
8.2.160.0030.01022.96
8.2.150.0070.00025.66
8.2.140.0000.00724.66
8.2.130.0040.00426.16
8.2.120.0000.00719.79
8.2.110.0090.00020.52
8.2.100.0090.00020.39
8.1.280.0110.00325.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00318.66
8.1.230.0030.00918.38
8.1.60.0030.00517.57

preferences:
40.21 ms | 400 KiB | 5 Q