3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isPalindrome(string &$str): bool { if (strlen($str) <= 1) { return true; // reached the middle of the palindrome successfully } if ($str[0] !== $str[strlen($str) - 1]) { return false; // outermost characters are not identical, halt processing } $str = substr($str, 1, -1); return (__FUNCTION__)($str); // traverse deeper and bubble outcome to top level } function sanitizePalindrome(&$str) { return preg_replace('/[^a-z]+/', '', strtolower($str)); } $tests = [ 'radar', 'f', 'neveroddoreven', 'foo', 'palindrome', 'Red rum, sir, is murder' ]; foreach ($tests as $test) { $test = sanitizePalindrome($test); // this is optional printf("%20s : %s\n", $test, json_encode(isPalindrome($test))); }

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.4.120.0050.00620.42
8.4.110.0030.00722.18
8.4.100.0150.00517.95
8.4.90.0100.01119.86
8.4.80.0140.00618.02
8.4.70.0090.01318.21
8.4.60.0140.00617.71
8.4.50.0080.00418.02
8.4.40.0130.00718.05
8.4.30.0070.01318.82
8.4.20.0130.00617.94
8.4.10.0160.00319.48
8.3.250.0140.00618.76
8.3.240.0140.00616.68
8.3.230.0090.00916.63
8.3.220.0050.00816.96
8.3.210.0040.00316.86
8.3.200.0110.00816.73
8.3.190.0090.01016.60
8.3.180.0040.00418.62
8.3.170.0050.00220.92
8.3.160.0070.01117.26
8.3.150.0160.00317.11
8.3.140.0070.01116.56
8.3.130.0030.00618.71
8.3.120.0030.00519.22
8.3.110.0090.00016.91
8.3.100.0050.00516.79
8.3.90.0080.00026.77
8.3.80.0120.00019.36
8.3.70.0150.00418.30
8.3.60.0150.00018.78
8.3.50.0120.00616.70
8.3.40.0140.00021.84
8.3.30.0100.00721.92
8.3.20.0170.00325.66
8.3.10.0130.00625.66
8.3.00.0110.00825.66
8.2.290.0040.00520.61
8.2.280.0090.00720.22
8.2.270.0110.00819.07
8.2.260.0130.00618.30
8.2.250.0030.00518.41
8.2.240.0060.00316.83
8.2.230.0040.00420.94
8.2.220.0090.00324.06
8.2.210.0000.00826.77
8.2.200.0040.00818.88
8.2.190.0130.00917.00
8.2.180.0090.01216.63
8.2.170.0090.00919.08
8.2.160.0150.00422.96
8.2.150.0110.00725.66
8.2.140.0160.00325.66
8.2.130.0110.00425.66
8.2.120.0130.00725.66
8.2.110.0150.00425.66
8.2.100.0120.00625.66
8.2.90.0120.00325.66
8.2.80.0110.00425.66
8.2.70.0180.00425.66
8.2.60.0170.00325.66
8.2.50.0130.00625.66
8.2.40.0080.00825.66
8.2.30.0080.00025.66
8.2.20.0090.00925.66
8.2.10.0190.00025.66
8.2.00.0110.00725.66
8.1.330.0100.00817.05
8.1.320.0130.00716.34
8.1.310.0140.00016.67
8.1.300.0150.00018.03
8.1.290.0040.00430.84
8.1.280.0140.00725.92
8.1.270.0160.00025.66
8.1.260.0090.00625.66
8.1.250.0140.00425.66
8.1.240.0060.01225.66
8.1.230.0070.00725.66
8.1.220.0090.00025.66
8.1.210.0000.00825.66
8.1.200.0060.00325.66
8.1.190.0080.00025.66
8.1.180.0030.00525.66
8.1.170.0080.00025.66
8.1.160.0040.00425.66
8.1.150.0040.00425.66
8.1.140.0000.00925.66
8.1.130.0080.00025.66
8.1.120.0080.00025.66
8.1.110.0030.00625.66
8.1.100.0080.00025.66
8.1.90.0160.00325.66
8.1.80.0160.00425.66
8.1.70.0160.00325.66
8.1.60.0060.01025.66
8.1.50.0120.00325.66
8.1.40.0200.00325.66
8.1.30.0040.00825.66
8.1.20.0000.00925.66
8.1.10.0090.00625.66
8.1.00.0030.00625.66

preferences:
25.85 ms | 403 KiB | 5 Q