3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ImmutableClass { public function __construct( public readonly OtherClass $readonly_property, ) {} } class OtherClass { public function __construct( public int $foo = 0, public ?string $bar = null, ) {} } $object = new OtherClass(); $object->foo = 500; $immutable_object = new ImmutableClass(readonly_property: $object); var_dump($immutable_object->readonly_property); $immutable_object->readonly_property->foo = 100; $immutable_object->readonly_property->bar = 'oops'; var_dump($immutable_object->readonly_property);

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.4.120.0100.00320.32
8.4.110.0140.00819.42
8.4.100.0420.00817.47
8.4.90.0430.00817.74
8.4.80.0410.00917.48
8.4.70.0230.00717.61
8.4.60.0190.00317.75
8.4.50.0180.00617.59
8.4.40.0370.00517.45
8.4.30.0270.00317.36
8.4.20.0260.00517.31
8.4.10.0190.00517.46
8.3.250.0090.01017.29
8.3.240.0140.00416.95
8.3.230.0330.00916.17
8.3.220.0340.00816.36
8.3.210.0360.00416.36
8.3.200.0420.00816.66
8.3.190.0420.00816.23
8.3.180.0350.00616.27
8.3.170.0470.00816.29
8.3.160.0430.00916.20
8.3.150.0450.01316.16
8.3.140.0390.01016.53
8.3.130.0390.00716.38
8.3.120.0380.00816.41
8.3.110.0380.00816.20
8.3.100.0340.01416.46
8.3.90.0390.00716.28
8.3.80.0410.00716.34
8.3.70.0320.01116.40
8.3.60.0350.00716.27
8.3.50.0360.00616.53
8.3.40.0450.00517.35
8.3.30.0300.00917.45
8.3.20.0390.00517.50
8.3.10.0350.00917.49
8.3.00.0480.00717.21
8.2.290.0330.00716.51
8.2.280.0300.01016.77
8.2.270.0320.01016.40
8.2.260.0360.00716.42
8.2.250.0350.00616.43
8.2.240.0330.01016.34
8.2.230.0360.00716.30
8.2.220.0220.00416.56
8.2.210.0160.00516.30
8.2.200.0170.00416.17
8.2.190.0340.00916.34
8.2.180.0400.00716.36
8.2.170.0420.00617.54
8.2.160.0430.00917.40
8.2.150.0240.00517.53
8.2.140.0220.00217.33
8.2.130.0380.00717.27
8.2.120.0310.01217.33
8.2.110.0360.00817.54
8.2.100.0370.00717.52
8.2.90.0350.00817.41
8.2.80.0390.00717.49
8.2.70.0360.00917.50
8.2.60.0380.01117.33
8.2.50.0230.00617.54
8.2.40.0300.00617.37
8.2.30.0300.00817.40
8.2.20.0310.01017.45
8.2.10.0340.00317.48
8.2.00.0390.00917.14

preferences:
27.76 ms | 403 KiB | 5 Q