3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface PolicyRule { public function isSatisfiedBy(string $aValue); } abstract class EnforcedRule implements PolicyRule { const UNENFORCED = 0; const ENFORCED = 1; private $enforcementType; protected function isEnforced() : bool { return ($this->enforcementType == self::ENFORCED); } protected function setEnforcementType(int $aType) { $this->guardEnforcementType($aType); $this->enforcementType = $aType; } protected function guardEnforcementType(int $aType) { if (! in_array($aType, [self::UNENFORCED, self::ENFORCED])) { throw new InvalidEnforcementTypeException($aType); } } } abstract class MinimumCharacterCountRule extends EnforcedRule { const DEFAULT_MINIMUM = 1; protected $regexPattern; protected $minimumCount = self::DEFAULT_MINIMUM; public function isSatisfiedBy(string $aValue) : bool { if (! $this->isEnforced()) { return true; } $matches = []; preg_match_all($this->regexPattern, $aValue, $matches); return (count($matches[0]) >= $this->minimumCount); } } class NumericRule extends MinimumCharacterCountRule { protected $regexPattern = '/[0-9]/'; public function __construct(int $aMinimumCount = self::DEFAULT_MINIMUM, int $anEnforcementType = self::ENFORCED) { $this->setEnforcementType($anEnforcementType); $this->minimumCount = $aMinimumCount; } } class SpecialCharacterRule extends MinimumCharacterCountRule { protected $regexPattern = '/[~`#\$%\^&\*\(\)\-_\+\|,\.<>]/'; public function __construct(int $aMinimumCount = self::DEFAULT_MINIMUM, int $anEnforcementType = self::ENFORCED) { $this->setEnforcementType($anEnforcementType); $this->minimumCount = $aMinimumCount; } } $numeric = new NumericRule(); var_dump($numeric->isSatisfiedBy("for5")); $special = new SpecialCharacterRule(); var_dump($special->isSatisfiedBy("for5"));

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.0070.00718.55
8.3.50.0110.00822.04
8.3.40.0080.00819.10
8.3.30.0090.00619.11
8.3.20.0080.00020.20
8.3.10.0050.00323.52
8.3.00.0080.00019.63
8.2.180.0150.00018.16
8.2.170.0070.00722.96
8.2.160.0000.01420.36
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0090.00017.63
8.2.120.0040.00426.35
8.2.110.0080.00320.39
8.2.100.0140.00317.79
8.2.90.0040.00419.36
8.2.80.0030.00617.97
8.2.70.0060.00317.88
8.2.60.0040.00418.05
8.2.50.0040.00418.07
8.2.40.0050.00319.34
8.2.30.0000.00720.68
8.2.20.0060.00318.04
8.2.10.0040.00418.23
8.2.00.0000.00818.04
8.1.280.0150.00025.92
8.1.270.0000.00924.01
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0080.00422.01
8.1.230.0070.00420.91
8.1.220.0050.00317.77
8.1.210.0030.00518.77
8.1.200.0040.00417.36
8.1.190.0040.00417.70
8.1.180.0000.00918.10
8.1.170.0030.00718.82
8.1.160.0040.00422.06
8.1.150.0000.00718.93
8.1.140.0000.00819.50
8.1.130.0040.00417.75
8.1.120.0020.00517.55
8.1.110.0050.00217.55
8.1.100.0000.00717.65
8.1.90.0090.00017.59
8.1.80.0040.00417.59
8.1.70.0040.00417.63
8.1.60.0050.00317.81
8.1.50.0040.00417.69
8.1.40.0040.00417.59
8.1.30.0060.00317.85
8.1.20.0040.00417.70
8.1.10.0080.00017.76
8.1.00.0050.00317.61
8.0.300.0040.00418.84
8.0.290.0000.00717.00
8.0.280.0000.00718.48
8.0.270.0000.00717.30
8.0.260.0000.00717.29
8.0.250.0040.00417.11
8.0.240.0040.00417.01
8.0.230.0030.00317.12
8.0.220.0000.00717.04
8.0.210.0050.00317.00
8.0.200.0070.00417.13
8.0.190.0030.00617.19
8.0.180.0050.00316.99
8.0.170.0030.00617.04
8.0.160.0040.00417.04
8.0.150.0040.00416.96
8.0.140.0000.00816.91
8.0.130.0030.00313.41
8.0.120.0030.00517.02
8.0.110.0030.00517.05
8.0.100.0040.00416.93
8.0.90.0040.00417.03
8.0.80.0130.00616.94
8.0.70.0000.00817.00
8.0.60.0060.00317.02
8.0.50.0030.00517.07
8.0.30.0080.01017.34
8.0.20.0100.00917.40
8.0.10.0000.00716.96
8.0.00.0100.00816.92
7.4.330.0050.00016.67
7.4.320.0030.00316.81
7.4.300.0000.00716.65
7.4.290.0080.00016.78
7.4.280.0040.00416.78
7.4.270.0030.00316.75
7.4.260.0040.00416.74
7.4.250.0110.00016.75
7.4.240.0020.00516.85
7.4.230.0070.00016.64
7.4.220.0090.00716.90
7.4.210.0060.00916.95
7.4.200.0060.00316.64
7.4.160.0060.00916.70
7.4.150.0090.00917.40
7.4.140.0110.00817.86
7.4.130.0140.00316.66
7.4.120.0100.00816.74
7.4.110.0090.00916.81
7.4.100.0150.00316.74
7.4.90.0070.01316.63
7.4.80.0120.00919.39
7.4.70.0120.00416.67
7.4.60.0100.00716.53
7.4.50.0000.01416.61
7.4.40.0060.01116.52
7.4.30.0070.01016.76
7.4.00.0040.00815.30
7.3.330.0070.00013.49
7.3.320.0000.00513.50
7.3.310.0040.00416.41
7.3.300.0000.00816.46
7.3.290.0070.00816.42
7.3.280.0070.01216.51
7.3.270.0120.00617.40
7.3.260.0100.00716.72
7.3.250.0100.00916.60
7.3.240.0100.00716.74
7.3.230.0070.01016.50
7.3.210.0100.00716.73
7.3.200.0030.01516.69
7.3.190.0140.00716.72
7.3.180.0130.00516.68
7.3.170.0090.01316.46
7.3.160.0070.01016.63
7.3.120.0060.00614.93
7.3.110.0030.00714.96
7.3.100.0090.00615.13
7.3.90.0070.00315.02
7.3.80.0060.00914.66
7.3.70.0030.01215.00
7.3.60.0030.00614.94
7.3.50.0000.01415.25
7.3.40.0060.01215.06
7.3.30.0030.01315.02
7.3.20.0160.00016.70
7.3.10.0070.00716.87
7.3.00.0090.00616.86
7.2.330.0090.01216.92
7.2.320.0100.01316.90
7.2.310.0130.00316.66
7.2.300.0070.01016.84
7.2.290.0030.01316.87
7.2.240.0030.01415.46
7.2.230.0070.00415.30
7.2.220.0060.00915.54
7.2.210.0070.01015.34
7.2.200.0060.01015.34
7.2.190.0120.00415.28
7.2.180.0090.00615.18
7.2.170.0030.01415.32
7.2.160.0110.00415.10
7.2.150.0070.00716.89
7.2.140.0060.00916.89
7.2.130.0040.00716.88
7.2.120.0140.00317.18
7.2.110.0030.00917.02
7.2.100.0040.01217.22
7.2.90.0130.00317.00
7.2.80.0070.00316.86
7.2.70.0000.01616.97
7.2.60.0060.00817.07
7.2.50.0030.01316.82
7.2.40.0110.00717.14
7.2.30.0100.00616.85
7.2.20.0100.00717.20
7.2.10.0100.00617.07
7.2.00.0020.01018.39
7.1.330.0110.00415.88
7.1.320.0070.01015.93
7.1.310.0030.00816.00
7.1.300.0030.01316.08
7.1.290.0080.00815.79
7.1.280.0060.00615.72
7.1.270.0090.00615.80
7.1.260.0060.01215.92
7.1.250.0030.01016.17
7.1.200.0150.00415.61
7.1.100.0090.00318.50
7.1.70.0070.00717.24
7.1.60.0060.01919.36
7.1.50.0110.01116.89
7.1.00.0030.07022.49
7.0.200.0000.00716.71
7.0.60.0330.07719.89
7.0.50.0030.04317.92
7.0.40.0200.07020.07
7.0.30.0230.06720.17
7.0.20.0270.06720.11
7.0.10.0030.08320.32
7.0.00.0130.08020.08
5.6.280.0030.07020.82
5.6.210.0030.07020.47
5.6.200.0070.07718.18
5.6.190.0030.04320.68
5.6.180.0570.06720.47
5.6.170.0130.04320.48
5.6.160.0070.09020.57
5.6.150.0100.07718.12
5.6.140.0030.05318.15
5.6.130.0030.04718.15
5.6.120.0030.06721.13
5.6.110.0030.07721.03
5.6.100.0030.07721.07
5.6.90.0070.04021.11
5.6.80.0100.07720.36
5.5.350.0100.07320.32
5.5.340.0100.07017.93
5.5.330.0030.04320.35
5.5.320.0030.04720.30
5.5.310.0370.04320.29
5.5.300.0100.07017.98
5.5.290.0070.04317.97
5.5.280.0070.07020.80
5.5.270.0070.08320.96
5.5.260.0130.06320.89
5.5.250.0100.05720.69
5.5.240.0000.04020.34

preferences:
57.11 ms | 401 KiB | 5 Q