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.5.10.0080.01118.82
8.5.00.0110.01020.09
8.4.150.0030.00014.05
8.4.140.0110.01017.81
8.4.130.0100.01217.92
8.4.120.0020.00620.77
8.4.110.0130.00722.45
8.4.100.0130.00819.19
8.4.90.0030.00818.83
8.4.80.0100.00817.71
8.4.70.0090.01117.92
8.4.60.0150.00520.30
8.4.50.0090.01217.66
8.4.40.0060.00617.46
8.4.30.0130.00720.42
8.4.20.0030.01318.07
8.4.10.0070.01123.93
8.3.280.0140.00518.51
8.3.270.0130.00716.40
8.3.260.0100.00816.39
8.3.250.0130.00619.00
8.3.240.0100.00917.18
8.3.230.0130.00616.57
8.3.220.0140.00417.02
8.3.210.0090.00916.53
8.3.200.0080.01216.20
8.3.190.0100.00817.36
8.3.180.0110.00816.83
8.3.170.0070.01119.04
8.3.160.0000.01516.56
8.3.150.0100.00720.68
8.3.140.0030.00616.68
8.3.130.0080.00318.44
8.3.120.0070.01120.59
8.3.110.0090.00020.94
8.3.100.0090.00024.06
8.3.90.0070.00726.77
8.3.80.0070.00318.43
8.3.70.0120.00916.74
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.290.0090.01020.37
8.2.280.0130.00418.06
8.2.270.0070.01117.02
8.2.260.0140.00417.33
8.2.250.0000.00816.68
8.2.240.0080.00018.93
8.2.230.0080.00022.58
8.2.220.0000.00937.54
8.2.210.0040.00426.77
8.2.200.0070.00316.50
8.2.190.0100.01018.41
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.330.0100.00921.89
8.1.320.0110.00820.20
8.1.310.0070.00018.62
8.1.300.0130.00616.10
8.1.290.0030.00630.84
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:
44.04 ms | 403 KiB | 5 Q