3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Outside of the application, e.g. DB or some storage. function addSomeIntegerFieldToDB($value) { $sql = 'INSERT INTO mytable (integer_field) VALUES (:int)'; // $st = $pdo->prepare($sql); // $st->execute(array('int' => $value); echo "executing query: ".str_replace(':int', $value, $sql)." \n"; } // the application: global $conditional; class X { public function doSmth($id) { // Assertion will run independently of $conditional, thus preventing a wrong $id to be passed to ->doSmth() method assert(is_int($id), new \InvalidArgumentException('wot ar y doin')); global $conditional; if ($conditional) { addSomeIntegerFieldToDB($id); } } } $conditional = true; $obj = new X; $obj->doSmth(13); $obj->doSmth('x'); $obj->doSmth(000001234000); $conditional = false; $obj->doSmth(13); $obj->doSmth('x'); $obj->doSmth(000001234000);
based on Fg7X4

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0000.01616.88
7.2.00.0050.00819.38
7.1.200.0070.00715.54
7.1.100.0030.01118.21
7.1.70.0040.00417.23
7.1.60.0100.01419.19
7.1.50.0140.00016.82
7.1.00.0000.07722.45
7.0.200.0160.00314.65
7.0.60.0200.04319.88
7.0.50.0070.07717.74
7.0.40.0100.07720.20
7.0.30.0200.07020.17
7.0.20.0330.06720.12
7.0.10.0130.07720.06
7.0.00.0000.09020.06
5.6.280.0000.05021.13
5.6.210.0000.08020.51
5.6.200.0070.04018.25
5.6.190.0030.09020.64
5.6.180.0330.07720.57
5.6.170.0230.08020.51
5.6.160.0130.07720.57
5.6.150.0070.04018.15
5.6.140.0070.07318.16
5.6.130.0070.04718.27
5.6.120.0130.06321.15
5.6.110.0070.08721.01
5.6.100.0100.08320.96
5.6.90.0070.05321.14
5.6.80.0100.04020.52
5.5.350.4270.04020.44
5.5.340.0030.08718.02
5.5.330.0200.07320.27
5.5.320.0630.05020.27
5.5.310.0330.07320.36
5.5.300.0070.08017.94
5.5.290.0030.04017.93
5.5.280.0100.08320.83
5.5.270.0030.04320.80
5.5.260.0130.07320.88
5.5.250.0130.07720.59
5.5.240.0100.03720.16
5.4.450.0400.05319.46
5.4.440.0130.05719.63
5.4.430.0200.04719.48
5.4.420.0200.05019.30
5.4.410.0400.04319.41
5.4.400.0100.06019.13
5.4.390.0270.05019.31
5.4.380.0270.04019.10
5.4.370.0170.05019.19
5.4.360.0200.05019.19
5.4.350.0100.05719.14
5.4.340.0230.04719.22
5.4.320.0130.06019.30
5.4.310.0270.04319.10
5.4.300.0170.05319.20
5.4.290.0070.06019.21
5.4.280.0230.04719.19
5.4.270.0130.05719.21
5.4.260.0170.05318.94
5.4.250.0170.05319.28
5.4.240.0130.05719.21
5.4.230.0130.05719.28
5.4.220.0230.04719.16
5.4.210.0200.06019.21
5.4.200.0230.04718.97
5.4.190.0230.05018.93
5.4.180.0200.04719.04
5.4.170.0130.05319.09
5.4.160.0200.04719.23
5.4.150.0070.06319.17
5.4.140.0270.06016.47
5.4.130.0230.04316.47
5.4.120.0200.04716.48
5.3.290.0230.04714.69
5.3.280.0200.05014.82
5.3.270.0170.05314.68
5.3.260.0200.05014.84
5.3.250.0130.05314.82
5.3.240.0330.03714.78
5.3.230.0170.06314.49
5.3.220.0200.05314.69