3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { protected string $property; public function __construct(string $property) { $this->property = $property; } public function getProperty(): string { return $this->property; } } $foo = new Foo("foo"); echo "Default value:\n"; var_dump($foo->getProperty()); // ------------------------- Method 1 ------------------------- echo "\nInvoking the __constructor() method again:\n"; $foo->__construct("bar"); var_dump($foo->getProperty()); // ------------------------- Method 2 ------------------------- // https://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection/ echo "\nClosure binding:\n"; Closure::bind( function (): void { $this->property = "baz"; }, $foo, $foo )->__invoke(); var_dump($foo->getProperty()); // ------------------------- Method 3 ------------------------- echo "\nAbusing anonymous classes:\n"; $fooAbuser = new class("") extends Foo { public function abuse(Foo $foo): void { $foo->property = "boom"; } }; $fooAbuser->abuse($foo); var_dump($foo->getProperty());

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.5.90.0250.00716.68
8.5.80.0100.00416.97
8.5.70.0200.00916.80
8.5.60.0200.00416.84
8.5.50.0230.00616.63
8.5.40.0320.00816.71
8.5.30.0110.00717.20
8.5.20.0180.00518.16
8.5.10.0210.00917.75
8.5.00.0130.00718.38
8.4.240.0240.00919.62
8.4.230.0230.00919.44
8.4.220.0190.01219.56
8.4.210.0210.00919.52
8.4.200.0390.01119.55
8.4.190.0340.00919.37
8.4.180.0220.01119.60
8.4.170.0190.00920.82
8.4.160.0250.00720.94
8.4.150.0130.00717.84
8.4.140.0140.00817.64
8.4.130.0210.00917.86
8.4.120.0210.01121.00
8.4.110.0210.00718.39
8.4.100.0270.00917.76
8.4.90.0230.01019.06
8.4.80.0190.00718.38
8.4.70.0240.00819.34
8.4.60.0200.01117.73
8.4.50.0240.00817.64
8.4.40.0250.00817.58
8.4.30.0230.01018.13
8.4.20.0200.01217.75
8.4.10.0170.00818.35
8.3.330.0180.00618.36
8.3.320.0100.00318.52
8.3.310.0170.01018.52
8.3.300.0230.00718.38
8.3.290.0230.01019.51
8.3.280.0210.01218.38
8.3.270.0200.00916.59
8.3.260.0180.00716.72
8.3.250.0220.00717.78
8.3.240.0250.00616.76
8.3.230.0200.00816.76
8.3.220.0220.00817.79
8.3.210.0210.00816.65
8.3.200.0220.00816.60
8.3.190.0260.00616.74
8.3.180.0190.00617.55
8.3.170.0230.00918.65
8.3.160.0250.00616.77
8.3.150.0200.01216.90
8.3.140.0200.00617.66
8.3.130.0170.00616.65
8.3.120.0170.00718.77
8.3.110.0190.00518.76
8.3.100.0130.00420.52
8.3.90.0120.00721.70
8.3.80.0190.00816.59
8.3.70.0260.00716.80
8.3.60.0220.00717.50
8.3.50.0150.00721.37
8.3.40.0230.00818.51
8.3.30.0190.00618.39
8.3.20.0130.00819.35
8.3.10.0150.00619.10
8.3.00.0120.00619.40
8.2.330.0430.00717.50
8.2.320.0230.00718.05
8.2.310.0230.00618.07
8.2.300.0170.00520.04
8.2.290.0210.00618.60
8.2.280.0170.00517.77
8.2.270.0210.00716.98
8.2.260.0150.00517.67
8.2.250.0090.00517.57
8.2.240.0100.00516.88
8.2.230.0140.00319.49
8.2.220.0100.00727.08
8.2.210.0170.00721.56
8.2.200.0120.01016.60
8.2.190.0200.00716.59
8.2.180.0180.00717.30
8.2.170.0190.00620.46
8.2.160.0150.01019.23
8.2.150.0160.00521.10
8.2.140.0160.00521.31
8.2.130.0150.00621.92
8.2.120.0150.00718.60
8.2.110.0150.00819.96
8.2.100.0170.00717.80
8.2.90.0150.00617.75
8.2.80.0130.00818.31
8.2.70.0150.00617.97
8.2.60.0190.00617.92
8.2.50.0170.00718.39
8.2.40.0170.00519.38
8.2.30.0130.00818.43
8.2.20.0130.00917.84
8.2.10.0170.00518.46
8.2.00.0140.00318.44
8.1.340.0180.00720.41
8.1.330.0120.00519.11
8.1.320.0120.00616.28
8.1.310.0140.00416.43
8.1.300.0080.00716.97
8.1.290.0180.00417.45
8.1.280.0210.00521.00
8.1.270.0180.00519.93
8.1.260.0180.00522.03
8.1.250.0110.01022.88
8.1.240.0140.00818.17
8.1.230.0170.00917.77
8.1.220.0180.00417.64
8.1.210.0160.00518.19
8.1.200.0160.00317.40
8.1.190.0140.00617.46
8.1.180.0150.00618.24
8.1.170.0170.00717.99
8.1.160.0180.00418.17
8.1.150.0160.00518.29
8.1.140.0180.00518.15
8.1.130.0180.00319.74
8.1.120.0170.00417.59
8.1.110.0160.00517.49
8.1.100.0140.00817.57
8.1.90.0150.00917.50
8.1.80.0200.00317.50
8.1.70.0160.00517.51
8.1.60.0190.00317.69
8.1.50.0180.00417.59
8.1.40.0150.00617.70
8.1.30.0180.00417.81
8.1.20.0170.00717.78
8.1.10.0140.00417.72
8.1.00.0170.00517.60
8.0.300.0140.00717.93
8.0.290.0140.00516.93
8.0.280.0160.00517.72
8.0.270.0160.00516.82
8.0.260.0140.00718.62
8.0.250.0140.00617.09
8.0.240.0130.00716.98
8.0.230.0140.00517.13
8.0.220.0160.00516.94
8.0.210.0160.00617.04
8.0.200.0150.00716.95
8.0.190.0120.00716.98
8.0.180.0160.00617.03
8.0.170.0180.00317.00
8.0.160.0130.00717.08
8.0.150.0150.00616.81
8.0.140.0150.00316.97
8.0.130.0070.00415.23
8.0.120.0120.00816.91
8.0.110.0160.00416.77
8.0.100.0140.00616.84
8.0.90.0180.00317.00
8.0.80.0170.00516.91
8.0.70.0160.00816.88
8.0.60.0150.00916.88
8.0.50.0130.00816.85
8.0.30.0160.01116.72
8.0.20.0140.01017.17
8.0.10.0130.00417.12
8.0.00.0190.00816.98
7.4.330.0140.00216.10
7.4.320.0150.00416.68
7.4.300.0140.00616.65
7.4.290.0150.00616.54
7.4.280.0150.00516.54
7.4.270.0160.00616.45
7.4.260.0120.00514.91
7.4.250.0160.00416.53
7.4.240.0100.00616.63
7.4.230.0150.00516.56
7.4.220.0110.00516.59
7.4.210.0120.00716.62
7.4.200.0130.00716.64
7.4.190.0260.00816.49
7.4.180.0260.00516.88
7.4.160.0260.00716.82
7.4.150.0290.01016.75
7.4.140.0280.00616.50
7.4.130.0130.00916.55
7.4.120.0160.00916.54
7.4.110.0170.00816.53
7.4.100.0170.00716.56
7.4.90.0190.00616.47
7.4.80.0220.00718.02
7.4.70.0130.01316.57
7.4.60.0170.00816.53
7.4.50.0160.01016.58
7.4.40.0180.00716.58
7.4.30.0150.00916.58
7.4.20.0190.00616.44
7.4.10.0200.00316.34
7.4.00.0150.00916.58
7.3.330.0140.00516.25
7.3.320.0160.00614.68
7.3.310.0160.00416.17
7.3.300.0130.00616.26
7.3.290.0130.00616.23
7.3.280.0170.00416.27
7.3.270.0250.00616.38
7.3.260.0160.00716.23
7.3.250.0220.00816.30
7.3.240.0130.00716.21
7.3.230.0160.00716.25
7.3.220.0270.00516.27
7.3.210.0190.00516.08
7.3.200.0150.00716.32
7.3.190.0160.00416.24
7.3.180.0130.00916.32
7.3.170.0200.00716.10
7.3.160.0140.01116.25
7.3.150.0130.01016.18
7.3.140.0180.00616.17
7.3.130.0130.00916.14
7.3.120.0140.00916.27
7.3.110.0160.00716.15
7.3.100.0170.00716.07
7.3.90.0150.00816.27
7.3.80.0170.00616.27
7.3.70.0160.00716.28
7.3.60.0120.01116.32
7.3.50.0120.01016.31
7.3.40.0140.00816.16
7.3.30.0180.00616.29
7.3.20.0260.00617.29
7.3.10.0180.00717.02
7.3.00.0150.00817.11
7.2.340.0210.00916.23
7.2.330.0180.00916.24
7.2.320.0160.00716.15
7.2.310.0170.00616.28
7.2.300.0170.01016.38
7.2.290.0160.00716.37
7.2.280.0160.00816.46
7.2.270.0180.00816.22
7.2.260.0210.00616.18
7.2.250.0180.00716.35
7.2.240.0120.01316.42
7.2.230.0150.00916.28
7.2.220.0160.00816.26
7.2.210.0170.00916.10
7.2.200.0170.00716.37
7.2.190.0150.00816.34
7.2.180.0140.01116.38
7.2.170.0220.00116.44
7.2.160.0160.00716.30
7.2.150.0230.00717.29
7.2.140.0160.00717.34
7.2.130.0150.00717.39
7.2.120.0160.00717.39
7.2.110.0180.01117.20
7.2.100.0160.01017.15
7.2.90.0140.00917.41
7.2.80.0240.00617.36
7.2.70.0170.00617.34
7.2.60.0210.00817.21
7.2.50.0200.00717.23
7.2.40.0170.00717.29
7.2.30.0150.00817.43
7.2.20.0160.00817.34
7.2.10.0210.00517.38
7.2.00.0190.00517.32

preferences:
55.78 ms | 1641 KiB | 5 Q