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; } } if (isset($options['startsWith'])) { $needle = StringFilter::check($options['startsWith']); if (false === self::startsWith($value, $needle)) { return false; } } if (isset($options['endsWith'])) { $needle = StringFilter::check($options['endsWith']); if (false === self::endsWith($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 ', ['empty' => false]));

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.00618.30
8.3.50.0060.00916.58
8.3.40.0040.01118.61
8.3.30.0060.00918.71
8.3.20.0030.00619.00
8.3.10.0040.00421.73
8.3.00.0000.00720.84
8.2.180.0170.00318.54
8.2.170.0100.01022.96
8.2.160.0090.00622.02
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00022.08
8.2.120.0040.00426.35
8.2.110.0070.00320.52
8.2.100.0040.00817.84
8.2.90.0040.00419.22
8.2.80.0060.00318.05
8.2.70.0030.00617.63
8.2.60.0050.00318.03
8.2.50.0040.00418.10
8.2.40.0040.00422.32
8.2.30.0030.00619.33
8.2.20.0000.00718.07
8.2.10.0080.00018.21
8.2.00.0040.00418.09
8.1.280.0130.00625.92
8.1.270.0000.00822.05
8.1.260.0070.00026.35
8.1.250.0000.00728.09
8.1.240.0100.00022.76
8.1.230.0040.00819.16
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0000.01017.35
8.1.190.0040.00417.23
8.1.180.0060.00318.10
8.1.170.0030.00518.63
8.1.160.0060.00319.05
8.1.150.0070.00018.99
8.1.140.0100.00019.67
8.1.130.0000.00718.84
8.1.120.0000.00717.52
8.1.110.0050.00317.39
8.1.100.0040.00417.48
8.1.90.0000.01217.48
8.1.80.0000.00717.46
8.1.70.0040.00417.53
8.1.60.0040.00417.70
8.1.50.0040.00417.61
8.1.40.0030.00617.65
8.1.30.0020.00517.62
8.1.20.0000.00817.79
8.1.10.0040.00417.61
8.1.00.0000.00817.49
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0000.00718.61
8.0.270.0000.00717.34
8.0.260.0030.00316.79
8.0.250.0000.00717.02
8.0.240.0060.00317.06
8.0.230.0030.00516.99
8.0.220.0000.00716.90
8.0.210.0070.00017.03
8.0.200.0000.00717.06
8.0.190.0000.00816.96
8.0.180.0050.00317.04
8.0.170.0000.00817.03
8.0.160.0040.00416.97
8.0.150.0050.00317.02
8.0.140.0070.00016.96
8.0.130.0030.00313.41
8.0.120.0000.00716.98
8.0.110.0000.00717.02
8.0.100.0000.00716.87
8.0.90.0000.00816.88
8.0.80.0040.01317.04
8.0.70.0040.00416.85
8.0.60.0030.00516.82
8.0.50.0000.00716.81
8.0.30.0100.00916.98
8.0.20.0090.01017.40
8.0.10.0040.00416.87
8.0.00.0040.01416.77
7.4.330.0050.00015.55
7.4.320.0000.00716.70
7.4.300.0030.00316.46
7.4.290.0030.00716.46
7.4.280.0080.00016.64
7.4.270.0000.00716.65
7.4.260.0030.00313.30
7.4.250.0030.00316.46
7.4.240.0000.00816.64
7.4.230.0030.00316.74
7.4.220.0100.01016.65
7.4.210.0110.00316.60
7.4.200.0030.00516.54
7.4.160.0120.00916.57
7.4.150.0070.01017.40
7.4.140.0080.00917.86
7.4.130.0110.00716.59
7.4.120.0110.00916.66
7.4.110.0100.00716.58
7.4.100.0070.01016.61
7.4.90.0060.01116.61
7.4.80.0120.01219.39
7.4.70.0160.00016.74
7.4.60.0130.00316.46
7.4.50.0030.01216.70
7.4.40.0140.00416.49
7.4.30.0150.00316.67
7.4.00.0090.00914.99
7.3.330.0050.00013.39
7.3.320.0030.00313.18
7.3.310.0000.00716.50
7.3.300.0040.00416.27
7.3.290.0090.00616.40
7.3.280.0080.00916.36
7.3.270.0100.01017.40
7.3.260.0070.01316.53
7.3.250.0120.00916.40
7.3.240.0100.00716.49
7.3.230.0130.00616.39
7.3.210.0160.00016.67
7.3.200.0070.01016.36
7.3.190.0050.01016.32
7.3.180.0140.00316.57
7.3.170.0140.00416.50
7.3.160.0150.00616.50
7.3.120.0110.00614.90
7.3.110.0100.00615.07
7.3.100.0020.01314.73
7.3.90.0030.00814.84
7.3.80.0060.00714.60
7.3.70.0080.00214.78
7.3.60.0050.01014.83
7.3.50.0100.00614.74
7.3.40.0070.00815.02
7.3.30.0040.01014.58
7.3.20.0070.00316.88
7.3.10.0080.00516.80
7.3.00.0070.00916.79
7.2.330.0060.01116.81
7.2.320.0120.00616.49
7.2.310.0140.01016.81
7.2.300.0030.01916.73
7.2.290.0110.01116.57
7.2.250.0050.01415.15
7.2.240.0040.01615.07
7.2.230.0030.01315.23
7.2.220.0050.00915.14
7.2.210.0080.00715.23
7.2.200.0070.00615.09
7.2.190.0070.00815.13
7.2.180.0030.01415.11
7.2.170.0030.00915.06
7.2.60.0060.00316.85
7.1.330.0110.00315.78
7.1.320.0050.00615.85
7.1.310.0050.00715.61
7.1.300.0020.01315.68
7.1.290.0070.00715.90
7.1.280.0080.00515.75
7.1.270.0030.00915.73
7.1.260.0070.00615.76
7.1.200.0090.00315.92
7.1.70.0150.00417.25
7.1.60.0170.00735.21
7.1.50.0170.00734.86
7.1.40.0030.02034.55
7.1.30.0230.00334.62
7.1.20.0170.01034.68
7.1.10.0000.01316.83
7.1.00.0030.00716.67
7.0.200.0000.01016.84
7.0.190.0000.01016.41
7.0.180.0000.01016.25
7.0.170.0000.01016.27
7.0.160.0030.01016.36
7.0.150.0000.01016.24
7.0.140.0000.01016.03
7.0.130.0000.01016.44
7.0.120.0000.01016.42
7.0.110.0070.00316.28
7.0.100.0030.00716.36
7.0.90.0030.00716.45
7.0.80.0000.01016.46
7.0.70.0030.00716.39
7.0.60.0000.01016.34
7.0.50.0000.01016.37
7.0.40.0030.00716.43
7.0.30.0030.00716.45
7.0.20.0030.00716.23
7.0.10.0030.00716.59
7.0.00.0070.00316.36

preferences:
56.64 ms | 400 KiB | 5 Q