3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* pseudo mysqli object */ class Foo { public $error; public function __construct($host, $user, $passwd, $dbname) { $this->host = $host; $this->user = $user; $this->pass = $passwd; $this->$dbname = $dbname; } public function query($sql, $resultmode) { if ($sql !== 'Valid Query') { $this->error = 'Expected "Valid Query"'; } return new Bar; } } /** pseudo mysql_stmt object */ class Bar { public function fetch_assoc() { echo 'I was successful'; } } class Conn { private $conn; public function __construct(...$args) { $this->conn = new Foo(...$args); } public function query($query, $resultmode = 1) { $d = $this->conn->query($query, $resultmode); if (!empty($this->conn->error)) { throw new \RuntimeException($this->conn->error); } return $d; } } //Your example $con = 'my_var'; $$con = new Conn('host', 'user', 'pass', 'base'); //example usage of valid query $q = $my_var->query('Valid Query'); $q->fetch_assoc(); echo PHP_EOL. '-----' . PHP_EOL; //example use of invalid query throwing an exception before `fetch_assoc` $q = $my_var->query('This is not valid'); $q->fetch_assoc();

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.140.0100.01117.73
8.4.130.0080.01217.92
8.4.120.0100.00923.99
8.4.110.0120.00822.57
8.4.100.0120.01017.86
8.4.90.0080.01220.75
8.4.80.0140.00618.87
8.4.70.0060.01318.14
8.4.60.0100.00620.48
8.4.50.0080.00618.24
8.4.40.0030.01719.38
8.4.30.0130.00617.64
8.4.20.0060.00320.36
8.4.10.0030.01317.80
8.3.270.0160.00516.78
8.3.260.0110.00816.76
8.3.250.0090.01119.08
8.3.240.0130.00617.39
8.3.230.0100.00916.70
8.3.220.0100.00919.16
8.3.210.0090.00616.65
8.3.200.0060.00316.74
8.3.190.0060.00318.98
8.3.180.0100.00916.89
8.3.170.0110.00718.97
8.3.160.0120.00818.63
8.3.150.0090.00921.03
8.3.140.0080.00016.67
8.3.130.0050.00518.50
8.3.120.0130.00720.80
8.3.110.0160.00020.94
8.3.100.0040.00418.49
8.3.90.0080.00026.77
8.3.80.0080.00016.75
8.3.70.0040.01418.57
8.3.60.0120.00616.88
8.3.50.0100.00418.33
8.3.40.0100.00718.92
8.3.30.0140.00018.77
8.3.20.0070.00019.30
8.3.10.0040.00423.66
8.3.00.0040.00420.57
8.2.290.0130.00519.04
8.2.280.0070.00318.55
8.2.270.0090.00917.09
8.2.260.0100.00720.27
8.2.250.0030.00616.59
8.2.240.0000.01917.44
8.2.230.0040.00422.58
8.2.220.0040.00424.06
8.2.210.0120.00326.77
8.2.200.0030.00618.54
8.2.190.0150.00016.75
8.2.180.0070.01018.54
8.2.170.0090.00922.96
8.2.160.0030.01020.57
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0000.00821.13
8.2.110.0040.00420.52
8.2.100.0040.00817.84
8.2.90.0040.00418.34
8.2.80.0050.00317.97
8.2.70.0000.00817.93
8.2.60.0030.00518.09
8.2.50.0050.00318.10
8.2.40.0040.00419.51
8.2.30.0000.00719.34
8.2.20.0100.00018.14
8.2.10.0050.00318.15
8.2.00.0040.00417.69
8.1.330.0050.00821.92
8.1.320.0110.00916.50
8.1.310.0060.01318.12
8.1.300.0000.00918.53
8.1.290.0030.00630.84
8.1.280.0120.00625.92
8.1.270.0060.00319.00
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00023.78
8.1.230.0080.00321.04
8.1.220.0050.00317.79
8.1.210.0040.00418.96
8.1.200.0060.00317.35
8.1.190.0000.00817.35
8.1.180.0030.00518.10
8.1.170.0040.00418.50
8.1.160.0080.00018.94
8.1.150.0040.00418.95
8.1.140.0030.00522.16
8.1.130.0040.00417.45
8.1.120.0000.00817.50
8.1.110.0040.00417.47
8.1.100.0000.00717.46
8.1.90.0030.00517.35
8.1.80.0070.00017.43
8.1.70.0000.00717.50
8.1.60.0040.00417.62
8.1.50.0000.00817.61
8.1.40.0000.00817.45
8.1.30.0050.00317.71
8.1.20.0110.00017.69
8.1.10.0000.00717.47
8.1.00.0000.00817.39
8.0.300.0040.00420.02
8.0.290.0020.00516.88
8.0.280.0030.00318.38
8.0.270.0030.00317.18
8.0.260.0030.00316.76
8.0.250.0000.00717.02
8.0.240.0070.00016.97
8.0.230.0050.00216.97
8.0.220.0070.00017.02
8.0.210.0000.00816.84
8.0.200.0000.00717.00
8.0.190.0000.00817.02
8.0.180.0070.00016.89
8.0.170.0040.00416.89
8.0.160.0070.00016.98
8.0.150.0040.00416.98
8.0.140.0060.00316.80
8.0.130.0030.00313.41
8.0.120.0030.00516.89
8.0.110.0000.00716.88
8.0.100.0030.00516.96
8.0.90.0040.00416.84
8.0.80.0080.01016.95
8.0.70.0050.00216.89
8.0.60.0000.00716.78
8.0.50.0040.00416.80
8.0.30.0120.00317.11
8.0.20.0060.01217.40
8.0.10.0000.00716.92
8.0.00.0140.00516.70
7.4.330.0050.00015.55
7.4.320.0060.00016.60
7.4.300.0030.00316.52
7.4.290.0040.00416.42
7.4.280.0030.00616.62
7.4.270.0040.00416.54
7.4.260.0040.00416.50
7.4.250.0000.00916.51
7.4.240.0000.00816.51
7.4.230.0020.00516.44
7.4.220.0030.00516.41
7.4.210.0120.00716.58
7.4.200.0070.00016.41
7.4.160.0080.00916.44
7.4.140.0130.00917.86
7.4.130.0030.01316.62
7.4.120.0100.01116.62
7.4.110.0100.01316.39
7.4.100.0120.00616.32
7.4.90.0120.00616.61
7.4.80.0110.00719.39
7.4.70.0060.01616.59
7.4.60.0030.01316.44
7.4.50.0140.00316.43
7.4.40.0080.00816.25
7.4.00.0030.01014.75
7.3.330.0020.00213.30
7.3.320.0030.00313.39
7.3.310.0030.00616.46
7.3.300.0040.00416.32
7.3.290.0000.00716.45
7.3.280.0100.00316.45
7.3.260.0100.00916.38
7.3.240.0100.01016.50
7.3.230.0060.01216.59
7.3.210.0130.00816.34
7.3.200.0030.01416.47
7.3.190.0070.01316.48
7.3.180.0100.00716.46
7.3.170.0060.01216.55
7.3.160.0070.01116.51
7.3.10.0060.00816.67
7.3.00.0100.00516.50
7.2.330.0070.01016.75
7.2.320.0030.01316.67
7.2.310.0080.00816.75
7.2.300.0040.01216.55
7.2.290.0070.01316.84
7.2.130.0100.00716.99
7.2.120.0080.00616.88
7.2.110.0110.00616.43
7.2.100.0120.00416.36
7.2.90.0120.00516.41
7.2.80.0100.00816.20
7.2.70.0150.00516.37
7.2.60.0120.00816.38
7.2.50.0120.00816.34
7.2.40.0140.00616.44
7.2.30.0120.00816.24
7.2.20.0110.00716.37
7.2.10.0080.01216.41
7.2.00.0310.00916.37
7.1.250.0070.00815.73
7.1.240.0110.00515.78
7.1.230.0530.00614.72
7.1.220.0150.00614.76
7.1.210.0180.00914.64
7.1.200.0140.00914.65
7.1.190.0190.00514.75
7.1.180.0250.00414.79
7.1.170.0140.01014.96
7.1.160.0170.00614.73
7.1.150.0170.00714.81
7.1.140.0130.01514.80
7.1.130.0180.01114.59
7.1.120.0130.00714.65
7.1.110.0120.00714.88
7.1.100.0130.00714.94
7.1.90.0160.00514.74
7.1.80.0140.00614.65
7.1.70.0130.00914.92
7.1.60.0230.00723.72
7.1.50.0230.00723.64
7.1.40.0230.00823.68
7.1.30.0330.00623.63
7.1.20.0270.01023.77
7.1.10.0230.00314.73
7.1.00.0220.00514.77
7.0.330.0110.00715.14
5.6.380.0070.00614.33

preferences:
104.68 ms | 403 KiB | 5 Q