3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Sealed class can not be created directly */ class Seal { private function __construct() { // private ctor prevents from direct creation of instance } } #1 Via traditional reflection without constructor $refClass = new ReflectionClass(Seal::class); $instance = $refClass->newInstanceWithoutConstructor(); var_dump($instance); #2 Via closure binding to the sealed class $instantinator = function () { return new static; }; $instantinator = $instantinator->bindTo(null, Seal::class); $instance = $instantinator(); var_dump($instance); #3 Via unserialize hack $instance = unserialize(sprintf('O:%d:"%s":0:{}', strlen(Seal::class), Seal::class)); var_dump($instance); #4 Via PDO, requires pdo_sqlite which is typically available, can be pdo_mysql, then change: SELECT "test" FROM DUAL if (phpversion('pdo_sqlite')) { $database = new PDO('sqlite::memory:'); $result = $database->query('SELECT "test" as field1'); // We can even initialize properties in the object $instance = $result->fetchObject(Seal::class); var_dump($instance); } #5 Via STOMP, requires php_stomp to be loaded if (phpversion('stomp')) { $connection = new Stomp(/* connection args */); $connection->subscribe('Test'); $connection->readFrame(Seal::class); }

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)
7.4.00.0120.00615.55
7.3.120.0060.01215.58
7.3.110.0070.01115.55
7.3.100.0070.00815.62
7.3.90.0040.01115.47
7.3.80.0060.00715.50
7.3.70.0060.00915.52
7.3.60.0050.01015.42
7.3.50.0040.01015.56
7.3.40.0060.00915.42
7.3.30.0040.00915.40
7.3.20.0070.01017.00
7.3.10.0070.00716.93
7.3.00.0090.00516.92
7.2.250.0060.01315.59
7.2.240.0130.00715.67
7.2.230.0060.00915.65
7.2.220.0050.01015.71
7.2.210.0080.00815.67
7.2.200.0060.00715.69
7.2.190.0080.00815.55
7.2.180.0060.00915.64
7.2.170.0080.00715.70
7.2.160.0040.01215.49
7.2.150.0160.00716.45
7.2.140.0090.00816.50
7.2.130.0080.00616.65
7.2.120.0070.01016.56
7.2.110.0080.00916.53
7.2.100.0100.01016.64
7.2.90.0110.00616.64
7.2.80.0670.00615.94
7.2.70.0430.00715.92
7.2.60.0410.01216.13
7.2.50.0520.00716.14
7.2.40.0490.00616.06
7.2.30.0450.00716.09
7.2.20.0500.01216.05
7.2.10.0410.00916.14
7.2.00.0420.01016.14
7.1.330.0080.00816.48
7.1.320.0060.00716.35
7.1.310.0080.00716.56
7.1.300.0070.00816.46
7.1.290.0080.00716.35
7.1.280.0060.00915.96
7.1.270.0060.00815.90
7.1.260.0090.00615.86
7.1.250.0060.00715.41
7.1.240.0120.00615.34
7.1.230.0170.00815.36
7.1.220.0090.00915.40
7.1.210.0370.01015.37
7.1.200.0150.00715.47
7.1.190.0510.00914.91
7.1.180.0480.00614.99
7.1.170.0460.00614.85
7.1.160.0600.00514.82
7.1.150.0460.00914.98
7.1.140.0500.01014.98
7.1.130.0550.00914.92
7.1.120.0680.00814.88
7.1.110.0610.00814.93
7.1.100.0650.00815.05
7.1.90.0630.01314.98
7.1.80.0580.00714.84
7.1.70.0700.00814.93
7.1.60.0720.01023.99
7.1.50.0990.00823.94
7.1.40.0820.01023.92
7.1.30.0840.01324.02
7.1.20.0970.00923.86
7.1.10.0890.01114.86
7.1.00.0780.00914.84
7.0.330.0220.00514.17
5.6.400.0150.01215.00
5.6.390.0180.00714.98
5.6.380.0210.00614.82

preferences:
26.01 ms | 401 KiB | 5 Q