3v4l.org

run code in 300+ 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.3.60.0160.00618.68
8.3.50.0030.01016.55
8.3.40.0140.00418.98
8.3.30.0110.00418.84
8.3.20.0070.00020.77
8.3.10.0040.00420.16
8.3.00.0000.00820.77
8.2.180.0110.00418.16
8.2.170.0100.00522.96
8.2.160.0040.01120.39
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0030.00619.36
8.2.110.0030.00622.16
8.2.100.0070.00717.84
8.2.90.0050.00317.75
8.2.80.0030.00518.73
8.2.70.0040.00418.05
8.2.60.0050.00318.22
8.2.50.0050.00319.09
8.2.40.0060.00321.20
8.2.30.0000.00719.25
8.2.20.0040.00418.13
8.2.10.0040.00419.16
8.2.00.0050.00219.16
8.1.280.0080.00625.92
8.1.270.0060.00322.20
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0060.00318.62
8.1.230.0040.00817.83
8.1.220.0080.00017.74
8.1.210.0060.00318.77
8.1.200.0080.00017.25
8.1.190.0030.00517.38
8.1.180.0040.00418.88
8.1.170.0070.00718.42
8.1.160.0080.00018.95
8.1.150.0040.00418.84
8.1.140.0040.00418.82
8.1.130.0070.00021.84
8.1.120.0080.00017.48
8.1.110.0050.00317.40
8.1.100.0030.00617.40
8.1.90.0000.00717.47
8.1.80.0090.00017.40
8.1.70.0040.00417.47
8.1.60.0090.00017.50
8.1.50.0070.00317.43
8.1.40.0030.00517.59
8.1.30.0080.00017.68
8.1.20.0030.00517.63
8.1.10.0090.00017.62
8.1.00.0060.00317.51
8.0.300.0000.00718.77
8.0.290.0020.00516.75
8.0.280.0030.00518.45
8.0.270.0050.00316.77
8.0.260.0030.00320.13
8.0.250.0000.00717.02
8.0.240.0000.00716.92
8.0.230.0030.00517.05
8.0.220.0030.00316.80
8.0.210.0040.00417.01
8.0.200.0000.00816.93
8.0.190.0040.00416.90
8.0.180.0080.00017.01
8.0.170.0060.00317.00
8.0.160.0000.00716.99
8.0.150.0000.00716.93
8.0.140.0070.00016.93
8.0.130.0000.00613.36
8.0.120.0000.00816.95
8.0.110.0070.00016.88
8.0.100.0000.00716.81
8.0.90.0060.00316.99
8.0.80.0110.00516.96
8.0.70.0000.00816.91
8.0.60.0030.00516.84
8.0.50.0000.00716.90
8.0.30.0030.01416.77
8.0.20.0090.01317.19
8.0.10.0040.00417.00
8.0.00.0170.01116.84
7.4.330.0050.00015.55
7.4.320.0030.00316.53
7.4.300.0000.00816.54
7.4.290.0020.00716.53
7.4.280.0040.00416.54
7.4.270.0030.00316.48
7.4.260.0000.00513.23
7.4.250.0050.00216.50
7.4.240.0010.00616.62
7.4.230.0050.00216.40
7.4.220.0040.00416.57
7.4.210.0090.00716.63
7.4.200.0000.00716.71
7.4.130.0080.01016.61
7.4.120.0080.01116.50
7.4.110.0090.00916.42
7.4.100.0100.00616.52
7.4.90.0120.00616.29
7.4.80.0160.00819.39
7.4.70.0030.01416.46
7.4.60.0070.01016.58
7.4.50.0070.01016.56
7.4.40.0070.01016.64
7.4.30.0040.01116.48
7.4.20.0130.00516.30
7.4.10.0130.00316.16
7.4.00.0030.01216.44
7.3.330.0040.00416.13
7.3.320.0040.00413.21
7.3.310.0030.00416.03
7.3.300.0000.00816.16
7.3.290.0110.00416.21
7.3.280.0140.00016.23
7.3.260.0090.00916.16
7.3.240.0100.00816.19
7.3.230.0100.00716.28
7.3.210.0110.00516.16
7.3.200.0070.01016.41
7.3.190.0100.00516.24
7.3.180.0040.01116.56
7.3.170.0160.00616.18
7.3.160.0040.01216.43
7.3.150.0040.01116.15
7.3.140.0100.00616.11
7.3.130.0050.01116.14
7.3.120.0040.01216.25
7.3.110.0070.01016.06
7.3.100.0120.00616.03
7.3.90.0060.01016.11
7.3.80.0080.00816.16
7.3.70.0060.00916.19
7.3.60.0000.01716.21
7.3.50.0040.01116.19
7.3.40.0060.00915.88
7.3.30.0120.00416.14
7.3.20.0140.01116.19
7.3.10.0210.00716.15
7.3.00.0060.00916.08
7.2.330.0120.01016.34
7.2.320.0090.00916.11
7.2.310.0100.00716.41
7.2.300.0100.01316.42
7.2.290.0090.00616.40
7.2.280.0070.01016.55
7.2.270.0080.00816.16
7.2.260.0090.00716.21
7.2.250.0100.00516.42
7.2.240.0060.01216.39
7.2.230.0080.00816.44
7.2.220.0030.01416.25
7.2.210.0080.01116.05
7.2.200.0110.00816.37
7.2.190.0040.01216.26
7.2.180.0040.01616.25
7.2.170.0170.00016.42
7.2.160.0080.00816.21
7.2.150.0110.00616.46
7.2.140.0100.00616.34
7.2.130.0060.01016.34
7.2.120.0090.00616.34
7.2.110.0070.01016.29
7.2.100.0060.00916.15
7.2.90.0080.00816.41
7.2.80.0180.00716.39
7.2.70.0100.00516.43
7.2.60.0180.00716.23
7.2.50.0140.00816.24
7.2.40.0120.00616.21
7.2.30.0120.00416.53
7.2.20.0080.00816.16
7.2.10.0120.00516.39
7.2.00.0130.00316.38

preferences:
67.87 ms | 401 KiB | 5 Q