3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Options { // This is OK but why redundant initialization? // public array $stack = []; public array $stack; public function __construct(array $stack) { $this->stack = $stack; } public function __set(string $name, $value) { // if (empty($this->stack)) { // // This line below yields: object(acme\Options)#1 (0) { ["stack"]=> uninitialized(array) }. // // return; // // This line below yields: object(acme\Options)#1 (1) { ["stack"]=> array(1) { ["stack"]=> array(1) { ["one"]=> int(1) } } }. // // $this->stack = []; // } // This is solving problem but the purpose is not that also corrupting $stack structure inserting a new sub-array. // object(acme\Options)#1 (1) { ["stack"]=> array(2) { ["one"]=> int(1) ["stack"]=> array(1) { ["one"]=> int(1) } } } // $this->stack = $value; // This is indicating that __set called before (before __construct). // throw new \Exception(); // This is problematic part. $this->stack[$name] = $value; } public function __get(string $name) { // This is indicating that __get called before (before __construct). // throw new \Exception(); return $this->stack[$name] ?? null; } } var_dump(new Options(['one' => 1]));

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.70.0120.00616.38
8.3.60.0110.00418.68
8.3.50.0040.01117.85
8.3.40.0060.00918.59
8.3.30.0070.00718.84
8.3.20.0040.00420.87
8.3.10.0040.00421.73
8.3.00.0070.00020.68
8.2.180.0100.00718.30
8.2.170.0070.00722.96
8.2.160.0120.00320.45
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0040.00426.16
8.2.110.0000.01121.07
8.2.100.0040.00817.59
8.2.90.0050.00317.50
8.2.80.0050.00318.75
8.2.70.0000.00817.92
8.2.60.0000.01017.97
8.2.50.0030.00618.10
8.2.40.0000.00821.07
8.2.30.0080.00319.25
8.2.20.0080.00017.89
8.2.10.0040.00418.72
8.2.00.0070.00019.09
8.1.280.0070.00725.92
8.1.270.0040.00420.64
8.1.260.0000.00726.35
8.1.250.0000.00828.09
8.1.240.0070.00423.73
8.1.230.0080.00422.75
8.1.220.0000.00818.38
8.1.210.0000.00818.77
8.1.200.0060.00317.22
8.1.190.0030.00617.11
8.1.180.0000.00818.95
8.1.170.0030.00618.59
8.1.160.0070.00020.30
8.1.150.0000.00818.77
8.1.140.0020.00518.64
8.1.130.0070.00020.09
8.1.120.0050.00317.35
8.1.110.0040.00417.33
8.1.100.0030.00517.29
8.1.90.0030.00617.29
8.1.80.0080.00017.34
8.1.70.0030.00517.36
8.1.60.0040.00417.53
8.1.50.0030.00617.52
8.1.40.0030.00517.41
8.1.30.0030.00617.64
8.1.20.0040.00417.53
8.1.10.0050.00317.47
8.1.00.0040.00417.47
8.0.300.0040.00419.95
8.0.290.0040.00416.63
8.0.280.0030.00318.39
8.0.270.0040.00417.39
8.0.260.0000.00620.05
8.0.250.0030.00616.91
8.0.240.0040.00416.90
8.0.230.0000.00716.79
8.0.220.0040.00416.87
8.0.210.0030.00616.79
8.0.200.0030.00316.88
8.0.190.0000.00716.87
8.0.180.0000.00816.78
8.0.170.0000.00916.87
8.0.160.0040.00416.82
8.0.150.0000.00816.75
8.0.140.0050.00316.78
8.0.130.0060.00013.14
8.0.120.0040.00416.68
8.0.110.0030.00316.89
8.0.100.0040.00416.73
8.0.90.0040.00416.83
8.0.80.0120.00916.76
8.0.70.0050.00216.71
8.0.60.0000.00716.87
8.0.50.0000.00716.89
8.0.30.0060.01316.95
8.0.20.0100.00916.98
8.0.10.0070.00016.85
8.0.00.0190.01316.61
7.4.330.0000.00515.55
7.4.320.0000.00616.49
7.4.300.0030.00316.55
7.4.290.0070.00016.59
7.4.280.0070.00016.58
7.4.270.0040.00416.57
7.4.260.0000.00513.24
7.4.250.0000.00716.39
7.4.240.0040.00416.57
7.4.230.0000.00716.69
7.4.220.0000.00716.42
7.4.210.0110.00916.52
7.4.200.0030.00316.63
7.4.130.0120.00616.57
7.4.120.0080.00916.41
7.4.110.0170.00016.42
7.4.100.0080.00816.54
7.4.90.0110.01116.43
7.4.80.0060.01019.39
7.4.70.0060.00916.51
7.4.60.0100.00616.39
7.4.50.0000.01516.28
7.4.40.0060.01116.44
7.3.330.0040.00416.25
7.3.320.0050.00013.10
7.3.310.0040.00416.27
7.3.300.0070.00016.17
7.3.290.0000.00616.07
7.3.280.0130.00316.17
7.3.260.0190.00316.29
7.3.240.0090.00716.33
7.3.230.0130.00316.18
7.3.210.0130.01016.32
7.3.200.0190.00416.57
7.3.190.0120.00316.24
7.3.180.0060.00916.07
7.3.170.0000.02016.19
7.3.160.0050.01116.37
7.3.120.0070.00714.38
7.3.110.0050.01414.74
7.3.100.0090.00514.66
7.3.90.0090.00614.55
7.3.80.0060.00914.65
7.3.70.0080.01114.55
7.3.60.0090.00614.54
7.3.50.0150.00914.75
7.3.40.0000.01314.27
7.3.30.0150.00414.58
7.3.20.0090.00614.64
7.3.10.0100.00314.48
7.3.00.0110.00314.70
7.2.330.0060.01316.44
7.2.320.0080.00816.40
7.2.310.0130.00316.52
7.2.300.0060.01816.45
7.2.290.0030.01516.46
7.2.240.0140.00514.93
7.2.230.0090.00614.57
7.2.220.0110.00814.72
7.2.210.0080.00614.88
7.2.200.0070.01014.55
7.2.190.0090.00614.76
7.2.180.0130.00714.54
7.2.170.0050.00914.49
7.2.160.0110.00914.85
7.2.150.0000.01414.56
7.2.140.0040.01114.72
7.2.130.0060.00914.59
7.2.120.0030.01514.69
7.2.110.0120.00414.71
7.2.100.0040.01214.65
7.2.90.0090.01514.69
7.2.80.0110.00714.79
7.2.70.0110.00514.99
7.2.60.0100.00614.62
7.2.50.0150.00315.00
7.2.40.0140.00814.67
7.2.30.0080.00814.70
7.2.20.0090.00914.92
7.2.10.0040.01614.66
7.2.00.0060.01014.72
7.1.330.0030.01513.58
7.1.320.0070.01013.39
7.1.310.0050.00913.46
7.1.300.0100.00313.60
7.1.290.0060.01013.74
7.1.280.0120.00313.57
7.1.270.0150.00813.55
7.1.260.0000.01313.54
7.1.250.0090.00313.49

preferences:
61.08 ms | 401 KiB | 5 Q