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 extends Filter { public static function check($value, array $options = array()) { return $value; } } final class StringFilter extends Filter { public static function check($value, array $options = array()) { // Trim if (false !== ($options['trim'] ?? true)) { $value = trim($value); } $length = mb_strlen($value, '8bit'); // Empty if (false === ($options['empty'] ?? true)) { if (0 === $length) { throw new LengthException('chaine vide !'); } } // Min & max length if (isset($options['max'])) { $maxLength = IntFilter::check($options['max'], ['min' => 1]); if ($length > $maxLength) { throw new LengthException('trop long !'); } } if (isset($options['min'])) { $minLength = IntFilter::check($options['min'], ['min' => 1]); if ($length < $minLength) { throw new LengthException('trop court !'); } } return $value; } } var_dump(StringFilter::check(' test ', ['max' => 5]));

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.56
8.3.50.0030.01016.25
8.3.40.0100.00518.69
8.3.30.0140.00018.58
8.3.20.0040.00420.16
8.3.10.0040.00421.94
8.3.00.0040.00420.80
8.2.180.0150.00318.25
8.2.170.0040.01122.96
8.2.160.0140.00022.05
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0050.00322.24
8.2.120.0000.00826.35
8.2.110.0130.00320.94
8.2.100.0040.00717.91
8.2.90.0030.00519.24
8.2.80.0080.00017.97
8.2.70.0050.00317.63
8.2.60.0030.00617.80
8.2.50.0040.00418.10
8.2.40.0040.00421.97
8.2.30.0060.00521.14
8.2.20.0000.00718.09
8.2.10.0040.00418.15
8.2.00.0000.00818.09
8.1.280.0000.01425.92
8.1.270.0040.00423.90
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0050.00520.81
8.1.230.0080.00317.89
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0100.00017.22
8.1.190.0000.00817.23
8.1.180.0060.00318.10
8.1.170.0050.00318.52
8.1.160.0000.00718.96
8.1.150.0080.00018.76
8.1.140.0000.01019.47
8.1.130.0000.00718.91
8.1.120.0030.00517.45
8.1.110.0080.00017.42
8.1.100.0040.00417.43
8.1.90.0000.00717.39
8.1.80.0040.00417.40
8.1.70.0050.00217.34
8.1.60.0030.00517.72
8.1.50.0050.00317.55
8.1.40.0000.00717.63
8.1.30.0030.00517.80
8.1.20.0040.00417.71
8.1.10.0040.00417.57
8.1.00.0040.00417.61
8.0.300.0030.00618.77
8.0.290.0000.00816.63
8.0.280.0000.00718.51
8.0.270.0030.00316.79
8.0.260.0090.00016.77
8.0.250.0030.00317.05
8.0.240.0040.00416.97
8.0.230.0040.00416.99
8.0.220.0030.00616.94
8.0.210.0030.00316.92
8.0.200.0030.00316.98
8.0.190.0060.00317.02
8.0.180.0030.00516.92
8.0.170.0000.00716.99
8.0.160.0040.00416.88
8.0.150.0000.00716.86
8.0.140.0030.00316.91
8.0.130.0000.00813.32
8.0.120.0000.00716.90
8.0.110.0030.00616.79
8.0.100.0080.00016.90
8.0.90.0070.00016.98
8.0.80.0130.01016.91
8.0.70.0050.00317.04
8.0.60.0000.00716.96
8.0.50.0060.00316.88
8.0.30.0110.00816.97
8.0.20.0100.01017.40
8.0.10.0050.00216.96
8.0.00.0130.00716.96
7.4.330.0000.00515.55
7.4.320.0000.00716.54
7.4.300.0070.00016.59
7.4.290.0040.00416.64
7.4.280.0040.00416.48
7.4.270.0040.00416.64
7.4.260.0030.00313.36
7.4.250.0050.00316.51
7.4.240.0000.00816.54
7.4.230.0040.00416.44
7.4.220.0160.00616.58
7.4.210.0090.00916.71
7.4.200.0030.00316.71
7.4.160.0110.00416.49
7.4.150.0170.00717.40
7.4.140.0150.00817.86
7.4.130.0130.01016.52
7.4.120.0080.01216.54
7.4.110.0110.00716.75
7.4.100.0160.00716.56
7.4.90.0090.00916.63
7.4.80.0060.01119.39
7.4.70.0060.00916.44
7.4.60.0100.01016.51
7.4.50.0080.00816.32
7.4.40.0060.00916.30
7.4.30.0060.01216.64
7.4.00.0090.00615.05
7.3.330.0030.00313.14
7.3.320.0000.00613.24
7.3.310.0070.00016.36
7.3.300.0030.00316.38
7.3.290.0080.00716.34
7.3.280.0090.00716.38
7.3.270.0060.01217.40
7.3.260.0110.00716.53
7.3.250.0100.01016.46
7.3.240.0090.00816.36
7.3.230.0120.00616.29
7.3.210.0320.02916.59
7.3.200.0030.01716.44
7.3.190.0070.00716.52
7.3.180.0110.00416.48
7.3.170.0090.01116.54
7.3.160.0060.01316.55
7.3.10.0140.00016.74
7.3.00.0080.00616.60
7.2.330.0120.00916.84
7.2.320.0150.00316.76
7.2.310.0070.01116.62
7.2.300.0080.00816.65
7.2.290.0100.01016.88
7.2.130.0080.00816.77
7.2.120.0070.00716.90
7.2.110.0060.00616.99
7.2.100.0040.01017.15
7.2.90.0040.01017.07
7.2.80.0000.01616.98
7.2.70.0070.00716.78
7.2.60.0070.00716.94
7.2.50.0030.01016.95
7.2.40.0060.00616.64
7.2.30.0080.00817.15
7.2.20.0070.00716.86
7.2.10.0090.00617.07
7.2.00.0060.00818.21
7.1.250.0030.00615.84
7.1.200.0100.00315.93
7.1.100.0030.00818.09
7.1.70.0030.00517.21
7.1.60.0700.01733.48
7.1.50.0730.01333.21
7.1.40.0600.01332.64
7.1.30.0730.01032.63
7.1.20.0500.02332.73
7.1.10.0470.01014.83
7.1.00.0600.01014.86
7.0.200.0800.00315.02
7.0.190.0700.00014.82
7.0.180.0730.00714.36
7.0.170.0670.00714.67
7.0.160.0600.01014.44
7.0.150.0930.01314.70
7.0.140.0570.00314.73
7.0.130.0500.01314.83
7.0.120.0570.01014.74
7.0.110.0500.01014.48
7.0.100.0530.00314.52
7.0.90.0530.00714.51
7.0.80.0530.00714.42
7.0.70.0500.01014.50
7.0.60.0630.00314.42
7.0.50.0570.01014.51
7.0.40.0670.01014.68
7.0.30.0570.00714.88
7.0.20.0700.00714.57
7.0.10.0530.01014.75
7.0.00.0530.01014.69

preferences:
51.26 ms | 400 KiB | 5 Q