3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Filter { abstract public static function check($value, array $options = array()); } final class IntFilter { public static function check($value, array $options = array()) { return $value; } } final class StringFilter { public static function check($value, array $options = array()) { if (false === is_string($value)) { return false; } if (false !== ($options['trim'] ?? true)) { $value = trim($value); } $length = mb_strlen($value, '8bit'); if ((false === ($options['empty'] ?? true)) && (0 === $length)) { return false; } if (isset($options['max'])) { $maxLength = IntFilter::check($options['max'], ['min' => 1]); if ($length > $maxLength) { return false; } } if (isset($options['min'])) { $minLength = IntFilter::check($options['min'], ['min' => 1]); if ($length < $minLength) { return false; } } foreach (['startsWith', 'endsWith'] as $name) { if (isset($options[$name])) { $needle = StringFilter::check($options[$name]); if (false === self::$name($value, $needle)) { return false; } } } return $value; } private static function startsWith($haystack, $needle) { return $haystack[0] === $needle[0] ? strncmp($haystack, $needle, mb_strlen($needle, '8bit')) === 0 : false; } private static function endsWith($haystack, $needle) { $length = mb_strlen($needle, '8bit'); $haystack = mb_substr($haystack, -$length); return $haystack[0] === $needle[0] ? strncmp($haystack, $needle, $length) === 0 : false; } } var_dump(StringFilter::check(' r a ', ['startsWith' => 'z']));

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.0170.00318.43
8.3.50.0130.00916.46
8.3.40.0060.00918.35
8.3.30.0140.00018.80
8.3.20.0180.00018.98
8.3.10.0000.00821.90
8.3.00.0040.00420.84
8.2.180.0070.01418.41
8.2.170.0060.01222.96
8.2.160.0140.00422.12
8.2.150.0110.00824.18
8.2.140.0030.00524.66
8.2.130.0050.00222.12
8.2.120.0070.00026.35
8.2.110.0000.01021.18
8.2.100.0040.00817.97
8.2.90.0050.00319.31
8.2.80.0000.00918.05
8.2.70.0040.00417.63
8.2.60.0030.00617.92
8.2.50.0040.00418.10
8.2.40.0060.00322.18
8.2.30.0020.00519.23
8.2.20.0040.00418.12
8.2.10.0000.00818.04
8.2.00.0000.00818.03
8.1.280.0200.00025.92
8.1.270.0000.00823.88
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0070.01023.97
8.1.230.0030.00719.21
8.1.220.0030.00517.78
8.1.210.0040.00418.77
8.1.200.0060.00617.35
8.1.190.0040.00417.22
8.1.180.0040.00418.10
8.1.170.0000.00918.43
8.1.160.0040.00419.10
8.1.150.0050.00218.85
8.1.140.0030.00619.63
8.1.130.0000.00818.81
8.1.120.0060.00317.52
8.1.110.0000.00717.53
8.1.100.0040.00417.54
8.1.90.0030.00817.42
8.1.80.0050.00317.38
8.1.70.0030.00317.48
8.1.60.0040.00417.61
8.1.50.0080.00017.69
8.1.40.0030.00517.55
8.1.30.0040.00417.78
8.1.20.0000.00717.71
8.1.10.0080.00017.75
8.1.00.0070.00017.64
8.0.300.0000.00718.77
8.0.290.0030.00616.88
8.0.280.0000.00718.64
8.0.270.0070.00017.27
8.0.260.0030.00316.88
8.0.250.0000.00717.07
8.0.240.0030.00616.95
8.0.230.0040.00417.07
8.0.220.0080.00017.03
8.0.210.0000.00716.89
8.0.200.0000.00616.97
8.0.190.0060.00316.93
8.0.180.0030.00617.05
8.0.170.0000.00817.01
8.0.160.0040.00316.91
8.0.150.0000.00816.99
8.0.140.0030.00516.91
8.0.130.0030.00313.48
8.0.120.0000.00716.91
8.0.110.0050.00317.04
8.0.100.0040.00416.81
8.0.90.0050.00316.88
8.0.80.0040.01116.96
8.0.70.0050.00216.93
8.0.60.0030.00516.95
8.0.50.0000.00717.06
8.0.30.0110.00817.17
8.0.20.0110.01317.40
8.0.10.0000.00717.07
8.0.00.0030.01516.97
7.4.330.0000.00615.55
7.4.320.0000.00716.54
7.4.300.0030.00316.64
7.4.290.0030.00516.65
7.4.280.0040.00416.52
7.4.270.0030.00316.57
7.4.260.0030.00313.28
7.4.250.0060.00316.53
7.4.240.0030.00516.66
7.4.230.0000.00716.70
7.4.220.0070.01116.45
7.4.210.0050.01016.60
7.4.200.0000.00716.67
7.4.160.0130.00516.59
7.4.150.0160.00617.40
7.4.140.0110.00917.86
7.4.130.0100.01016.50
7.4.120.0140.00616.53
7.4.110.0100.01016.84
7.4.100.0110.00716.57
7.4.90.0060.01216.65
7.4.80.0080.01419.39
7.4.70.0090.00616.45
7.4.60.0060.01016.64
7.4.50.0030.01016.36
7.4.40.0040.01716.52
7.4.30.0130.00616.55
7.4.00.0060.00914.88
7.3.330.0020.00213.47
7.3.320.0030.00313.41
7.3.310.0000.00716.32
7.3.300.0030.00316.25
7.3.290.0070.00016.34
7.3.280.0080.00916.40
7.3.270.0180.00017.40
7.3.260.0110.00916.35
7.3.250.0090.01116.48
7.3.240.0180.00016.49
7.3.230.0100.00716.52
7.3.210.0070.01616.52
7.3.200.0110.00716.61
7.3.190.0070.01116.63
7.3.180.0140.00716.52
7.3.170.0100.00716.37
7.3.160.0060.00916.64
7.3.120.0140.00014.57
7.3.110.0040.01114.79
7.3.100.0070.00015.12
7.3.90.0070.01014.75
7.3.80.0070.00714.60
7.3.70.0060.00714.79
7.3.60.0030.01214.91
7.3.50.0040.01214.66
7.3.40.0030.00714.66
7.3.30.0100.00714.89
7.3.20.0070.01116.71
7.3.10.0120.00416.46
7.3.00.0070.01016.73
7.2.330.0070.01016.38
7.2.320.0060.01216.73
7.2.310.0060.01016.80
7.2.300.0170.00616.79
7.2.290.0070.01716.74
7.2.240.0060.00615.08
7.2.230.0060.00915.27
7.2.220.0130.00015.05
7.2.210.0000.01215.29
7.2.200.0000.01214.93
7.2.190.0000.01115.28
7.2.180.0050.00514.80
7.2.170.0000.01815.23
7.2.160.0000.01015.05
7.2.150.0000.01216.85
7.2.140.0140.00017.00
7.2.130.0140.00416.73
7.2.120.0000.01617.07
7.2.110.0000.01216.85
7.2.100.0090.00916.93
7.2.90.0100.00716.73
7.2.80.0030.01016.89
7.2.70.0060.01216.98
7.2.60.0080.00616.80
7.2.50.0070.01016.93
7.2.40.0050.00516.73
7.2.30.0090.00616.95
7.2.20.0030.01416.88
7.2.10.0060.01216.91
7.2.00.0050.00918.05
7.1.330.0070.00715.77
7.1.320.0030.00915.68
7.1.310.0070.00715.72
7.1.300.0060.00615.62
7.1.290.0060.01015.85
7.1.280.0100.00315.54
7.1.270.0000.01315.89
7.1.260.0040.00815.93
7.1.250.0100.00715.90
7.1.200.0040.00815.91
7.1.100.0040.00817.82
7.1.70.0000.00816.86
7.1.60.0100.01335.24
7.1.50.0170.00735.05
7.1.40.0170.01034.45
7.1.30.0170.01034.30
7.1.20.0100.01734.85
7.1.10.0000.01316.58
7.1.00.0030.01316.82
7.0.200.0000.01016.70
7.0.190.0000.01016.72
7.0.180.0000.01016.43
7.0.170.0030.00716.20
7.0.160.0070.00316.19
7.0.150.0070.00316.23
7.0.140.0030.01016.28
7.0.130.0030.00716.34
7.0.120.0070.00316.49
7.0.110.0000.01016.31
7.0.100.0030.00716.15
7.0.90.0000.01016.29
7.0.80.0100.00016.32
7.0.70.0000.01016.30
7.0.60.0030.00716.00
7.0.50.0000.01016.32
7.0.40.0030.00716.66
7.0.30.0070.00316.70
7.0.20.0000.01016.68
7.0.10.0030.00716.36
7.0.00.0030.00716.39

preferences:
43.13 ms | 400 KiB | 5 Q