3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Length { public $violations = []; /** * Minimum length. * * @var int */ private $min; /** * Maximum length. * * @var int */ private $max; /** * Charset. * * @var string */ private $charset; /** * Length validation rule constructor. * * @param int $min * @param int $max * @param string $charset * @throws InvalidArgumentException * @throws LogicException */ public function __construct( $min = null, $max = null, $charset = 'UTF-8' ) { if ($min === null && $max === null) { throw new \InvalidArgumentException('Either option "min" or "max" must be given.'); } if ($max < $min) { throw new \LogicException('"Max" option cannot be less that "min".'); } $this->min = $min; $this->max = $max; $this->charset = $charset; } /** * Validates input. * * @param mixed $input * * @return bool */ public function isValid($input = null) { if ($input === null || $input === '') { return false; } $input = (string) $input; if (!$invalidCharset = !@mb_check_encoding($input, $this->charset)) { $length = mb_strlen($input, $this->charset); } if ($invalidCharset) { $this->violations[] = 'charset'; return false; } if ($this->max !== null && $length > $this->max) { $this->violations[] = 'max'; return false; } if ($this->min !== null && $length < $this->min) { $this->violations[] = 'min'; return false; } return true; } } $length = new Length(-100, ['a', 'b', 'c', 185, null]); $length->isValid(stream_context_create()); echo sprintf('Count fail violations: %d', count($length->violations));

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.0180.00316.63
8.3.50.0130.00721.09
8.3.40.0030.01218.97
8.3.30.0070.00718.85
8.3.20.0000.00820.73
8.3.10.0060.00323.71
8.3.00.0040.00422.46
8.2.180.0150.00625.92
8.2.170.0210.00018.79
8.2.160.0070.00720.52
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00021.10
8.2.110.0000.00920.94
8.2.100.0090.00317.72
8.2.90.0040.00419.22
8.2.80.0080.00017.97
8.2.70.0000.00817.38
8.2.60.0050.00517.80
8.2.50.0090.00318.10
8.2.40.0000.00720.42
8.2.30.0000.00819.28
8.2.20.0040.00417.71
8.2.10.0040.00418.06
8.2.00.0080.00018.08
8.1.280.0040.01125.92
8.1.270.0070.00024.66
8.1.260.0070.00026.35
8.1.250.0050.00328.09
8.1.240.0000.00921.19
8.1.230.0080.00417.42
8.1.220.0000.00817.76
8.1.210.0060.00318.77
8.1.200.0060.00317.35
8.1.190.0050.00317.22
8.1.180.0040.00418.10
8.1.170.0000.00818.64
8.1.160.0030.00322.00
8.1.150.0040.00419.04
8.1.140.0030.00519.72
8.1.130.0040.00417.69
8.1.120.0040.00417.46
8.1.110.0080.00017.55
8.1.100.0000.00717.53
8.1.90.0000.00717.52
8.1.80.0040.00617.57
8.1.70.0080.00417.51
8.1.60.0090.00417.57
8.1.50.0060.00717.46
8.1.40.0070.00317.55
8.1.30.0020.00917.64
8.1.20.0050.00517.64
8.1.10.0070.00517.63
8.1.00.0080.00517.57
8.0.300.0080.00018.77
8.0.290.0040.00416.63
8.0.280.0080.00018.48
8.0.270.0000.00817.38
8.0.260.0060.00317.23
8.0.250.0020.00517.02
8.0.240.0030.00317.10
8.0.230.0070.00017.04
8.0.220.0070.00016.92
8.0.210.0060.00516.89
8.0.200.0040.00716.93
8.0.190.0050.00617.02
8.0.180.0060.00516.76
8.0.170.0060.00416.89
8.0.160.0040.00717.03
8.0.150.0080.00216.79
8.0.140.0040.00316.81
8.0.130.0010.00615.09
8.0.120.0020.00616.95
8.0.110.0040.00416.97
8.0.100.0060.00416.94
8.0.90.0060.00516.96
8.0.80.0040.01016.87
8.0.70.0070.00416.77
8.0.60.0090.00316.94
8.0.50.0070.00416.88
8.0.30.0150.01017.00
8.0.20.0100.01117.29
8.0.10.0080.00416.94
8.0.00.0050.00916.86
7.4.330.0000.00615.20
7.4.320.0030.00316.70
7.4.300.0030.00716.70
7.4.290.0090.00316.68
7.4.280.0110.00416.63
7.4.270.0110.00116.53
7.4.260.0090.00416.49
7.4.250.0100.00216.58
7.4.240.0070.00316.64
7.4.230.0080.00216.54
7.4.220.0100.00716.72
7.4.210.0090.00616.63
7.4.200.0050.00616.47
7.4.190.0070.00716.71
7.4.180.0110.00016.48
7.4.160.0060.00816.56
7.4.150.0060.01216.90
7.4.140.0070.01017.43
7.4.130.0080.00816.50
7.4.120.0110.00616.48
7.4.110.0050.01016.51
7.4.100.0120.00416.62
7.4.90.0140.00016.47
7.4.80.0110.00317.84
7.4.70.0070.00816.56
7.4.60.0040.01016.36
7.4.50.0060.00716.46
7.4.40.0080.00516.41
7.4.30.0050.00716.53
7.4.20.0070.00316.58
7.4.10.0050.00915.58
7.4.00.0060.01015.38
7.3.330.0040.00714.75
7.3.320.0090.00314.96
7.3.310.0060.00516.40
7.3.300.0030.00816.35
7.3.290.0100.00816.43
7.3.280.0090.00816.44
7.3.270.0090.00716.93
7.3.260.0090.01016.44
7.3.250.0100.00916.43
7.3.240.0100.00816.29
7.3.230.0130.00316.38
7.3.220.0110.00616.29
7.3.210.0120.00416.52
7.3.200.0110.00616.24
7.3.190.0160.00216.41
7.3.180.0110.00616.35
7.3.170.0130.00316.36
7.3.160.0160.00316.35
7.3.150.0150.00016.18
7.3.140.0080.00816.28
7.3.130.0090.00815.62
7.3.120.0070.01015.60
7.3.110.0100.00615.52
7.3.100.0090.00415.52
7.3.90.0100.00615.73
7.3.80.0070.00715.63
7.3.70.0100.00215.54
7.3.60.0030.00815.52
7.3.50.0060.00915.65
7.3.40.0100.00415.65
7.3.30.0060.00715.63
7.3.20.0090.00517.44
7.3.10.0060.00717.06
7.3.00.0070.00417.08
7.2.340.0110.00516.43
7.2.330.0120.00516.57
7.2.320.0070.00916.60
7.2.310.0090.00716.56
7.2.300.0090.00716.50
7.2.290.0110.00516.72
7.2.280.0130.00316.53
7.2.270.0050.01016.43
7.2.260.0090.00715.92
7.2.250.0110.00515.77
7.2.240.0080.00815.70
7.2.230.0070.00815.82
7.2.220.0040.01115.74
7.2.210.0070.00415.89
7.2.200.0050.00815.91
7.2.190.0070.00815.72
7.2.180.0090.00615.93
7.2.170.0100.00415.90
7.2.160.0110.00215.86
7.2.150.0090.00317.59
7.2.140.0070.00817.60
7.2.130.0040.00717.24
7.2.120.0080.00517.34
7.2.110.0100.00517.32
7.2.100.0090.00517.33
7.2.90.0080.00617.34
7.2.80.0080.00817.30
7.2.70.0060.00717.37
7.2.60.0060.00717.22
7.2.50.0070.00817.50
7.2.40.0090.00517.38
7.2.30.0070.00717.27
7.2.20.0080.00617.33
7.2.10.0060.00817.32
7.2.00.0130.00617.65
7.1.330.0060.00716.52
7.1.320.0080.00616.45
7.1.310.0050.00716.64
7.1.300.0050.00816.56
7.1.290.0110.00316.73
7.1.280.0050.00916.71
7.1.270.0090.00516.66
7.1.260.0090.00316.71
7.1.250.0060.00716.14
7.1.240.0100.00516.54
7.1.230.0090.00416.51
7.1.220.0090.00516.50
7.1.210.0120.00116.49
7.1.200.0080.00616.43
7.1.190.0070.00616.63
7.1.180.0090.00416.59
7.1.170.0100.00116.44
7.1.160.0060.00816.53
7.1.150.0100.00416.53
7.1.140.0130.00216.45
7.1.130.0080.00816.60
7.1.120.0120.00116.65
7.1.110.0050.00716.43
7.1.100.0120.00316.72
7.1.90.0070.00716.62
7.1.80.0120.00216.71
7.1.70.0050.00716.81
7.1.60.0070.00817.76
7.1.50.0120.00016.75
7.1.40.0070.00716.62
7.1.30.0050.00816.69
7.1.20.0090.00616.53
7.1.10.0110.00316.73
7.1.00.0070.02818.38
7.0.330.0060.00716.18
7.0.320.0090.00516.12
7.0.310.0100.00616.09
7.0.300.0100.00616.22
7.0.290.0080.00316.14
7.0.280.0070.00716.10
7.0.270.0040.01016.22
7.0.260.0140.00016.20
7.0.250.0100.00116.31
7.0.240.0080.00716.22
7.0.230.0090.00316.23
7.0.220.0130.00016.32
7.0.210.0100.00216.28
7.0.200.0140.00815.76
7.0.190.0030.00816.19
7.0.180.0060.00616.30
7.0.170.0100.00316.44
7.0.160.0040.00816.12
7.0.150.0040.00916.16
7.0.140.0100.00616.18
7.0.130.0100.00216.19
7.0.120.0070.00516.37
7.0.110.0090.00516.27
7.0.100.0090.02717.50
7.0.90.0090.02617.50
7.0.80.0140.01917.38
7.0.70.0060.03617.40
7.0.60.0110.03117.57
7.0.50.0140.02717.61
7.0.40.0080.02216.99
7.0.30.0110.02316.84
7.0.20.0080.02616.85
7.0.10.0140.02417.02
7.0.00.0090.02216.93
5.6.400.0050.00914.99
5.6.390.0070.00715.21
5.6.380.0070.00415.11
5.6.370.0060.00915.07
5.6.360.0100.00414.99
5.6.350.0060.00615.10
5.6.340.0050.00915.05
5.6.330.0070.00715.16
5.6.320.0090.00515.19
5.6.310.0050.00915.30
5.6.300.0080.00615.12
5.6.290.0100.00315.11
5.6.280.0070.00815.33
5.6.270.0090.00615.11
5.6.260.0060.00715.28
5.6.250.0150.02617.10
5.6.240.0070.03217.06
5.6.230.0100.02117.03
5.6.220.0040.03717.08
5.6.210.0070.03517.00
5.6.200.0130.02917.23
5.6.190.0040.02917.17
5.6.180.0080.03017.18
5.6.170.0070.02917.18
5.6.160.0100.03117.16
5.6.150.0070.03417.14
5.6.140.0070.02717.25
5.6.130.0050.03117.06
5.6.120.0120.02817.12
5.6.110.0120.02817.15
5.6.100.0110.02517.10
5.6.90.0070.02917.16
5.6.80.0110.02116.76
5.6.70.0090.02416.89
5.6.60.0100.02216.97
5.6.50.0040.02716.82
5.6.40.0060.02616.88
5.6.30.0120.02217.02
5.6.20.0090.02316.82
5.6.10.0110.02016.86
5.6.00.0100.02216.84

preferences:
51.9 ms | 401 KiB | 5 Q