3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Singleton{ final public static function get_instance(...$args) { static $instance = []; $called_class = get_called_class(); if( !isset( $instance[ $called_class ] ) ) { $instance[$called_class] = new $called_class(...$args); } return $instance[ $called_class ]; } } class Database { use Singleton; protected function __construct(public readonly string $username, public readonly string $password) { } } Database::get_instance('admin', 'admin'); var_dump(Database::get_instance('readonly', 'readonly')); var_dump(Database::get_instance());

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.10.0100.00620.16
8.5.00.0130.00820.21
8.4.160.0100.01123.98
8.4.150.0020.00014.05
8.4.140.0130.00817.53
8.4.130.0140.00717.59
8.4.120.0140.00620.58
8.4.110.0120.00822.34
8.4.100.0130.00718.03
8.4.90.0120.00918.74
8.4.80.0040.00417.91
8.4.70.0120.00817.82
8.4.60.0040.00423.92
8.4.50.0110.01018.76
8.4.40.0070.01320.62
8.4.30.0090.01020.52
8.4.20.0120.00917.73
8.4.10.0200.00323.77
8.3.280.0090.01118.41
8.3.270.0100.01016.63
8.3.260.0110.00816.78
8.3.250.0040.00518.98
8.3.240.0110.00816.75
8.3.230.0120.00816.62
8.3.220.0130.00517.20
8.3.210.0090.01018.50
8.3.200.0050.00416.54
8.3.190.0040.00417.16
8.3.180.0100.00816.63
8.3.170.0090.00017.21
8.3.160.0180.00016.63
8.3.150.0110.00718.36
8.3.140.0110.00717.43
8.3.130.0070.01118.31
8.3.120.0000.00817.14
8.3.110.0080.00016.23
8.3.100.0040.00416.86
8.3.50.0050.00316.63
8.2.290.0110.00620.32
8.2.280.0120.00618.36
8.2.270.0070.01117.32
8.2.260.0040.00416.60
8.2.250.0000.00816.63
8.2.240.0030.00517.50
8.2.230.0060.00316.75
8.2.220.0040.00416.79
8.2.20.0050.00417.70
8.1.330.0100.00922.10
8.1.320.0120.00816.03
8.1.310.0080.00018.18
8.1.300.0030.00617.91
8.1.240.0210.00919.38
8.0.00.0060.01018.34
7.4.260.0090.00817.29

preferences:
78.14 ms | 403 KiB | 5 Q