3v4l.org

run code in 300+ PHP versions simultaneously
<?php class database{ // @object, The PDO object private $pdo; private $db_connected, $error; private $stmt; public function __construct($host, $dbname, $user, $pass, $char_set="utf8"){ $dsn = 'mysql:dbname='.$dbname.';host='.$host.''; try{ $this->pdo = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES ".$char_set)); // We can now log any exceptions on Fatal error. $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Disable emulation of prepared statements, use REAL prepared statements instead. $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $this->db_connected = true; }catch (PDOException $e){ die("Error! Could not connect to the database.<br />".$e->getMessage()); } } public function __destruct(){ $this->pdo = null; $this->db_connected = false; } public function query($query){ try{ $this->stmt = $this->pdo->prepare($query); }catch(PDOException $e){ if( _safemode_ ){ die("Error! Invalid Query.<br />".$query."<br />".$e->getMessage()); } else{ die("A fatal error occurred."); } } } public function bind($param, $value, $type = null){ if ( is_null($type) ){ switch(true){ case is_int($value): $type = PDO::PARAM_INT; break; case is_bool($value): $type = PDO::PARAM_BOOL; break; case is_null($value): $type = PDO::PARAM_NULL; break; default: $type = PDO::PARAM_STR; } } $this->stmt->bindValue($param, $value, $type); } public function execute(){ try{ $this->stmt->execute(); return true; }catch(PDOException $e){ $this->error = $e->getMessage(); return false; } } public function run(){ $this->execute(); } public function results(){ $this->execute(); return $this->stmt->fetchAll(PDO::FETCH_ASSOC); } public function single(){ $this->execute(); return $this->stmt->fetch(PDO::FETCH_ASSOC); } public function num_rows(){ return $this->stmt->rowCount(); } public function last_insert_id(){ return $this->pdo->lastInsertId(); } public function begin_transaction(){ return $this->pdo->beginTransaction(); } public function end_transaction(){ return $this->pdo->commit(); } public function cancel_transaction(){ return $this->pdo->rollBack(); } public function dump(){ return $this->stmt->debugDumpParams(); } } class MainClass{ protected $database; function __construct(){ $this->database = new database(DB_HOST, DB_NAME, DB_USER, DB_PASSWORD); } } class TheClass extends MainClass{ function SomeFunction(){ $this->database->query("some query text..."); } } $foo = new TheClass(); $foo->SomeFunction();

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.3.60.0100.01018.30
8.3.50.0040.01621.14
8.3.40.0110.00718.91
8.3.30.0070.00719.22
8.3.20.0100.00020.20
8.3.10.0050.00322.04
8.3.00.0070.00022.40
8.2.180.0160.00716.49
8.2.170.0040.01122.96
8.2.160.0060.00919.04
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0030.00526.16
8.2.120.0080.00019.36
8.2.110.0100.00022.17
8.2.100.0040.00719.45
8.2.90.0040.00419.11
8.2.80.0060.00319.59
8.2.70.0030.00617.63
8.2.60.0080.00018.16
8.2.50.0040.00418.07
8.2.40.0030.00519.95
8.2.30.0040.00418.02
8.2.20.0000.00717.80
8.2.10.0000.00717.84
8.2.00.0000.00817.82
8.1.280.0160.00325.92
8.1.270.0030.00622.31
8.1.260.0090.00926.35
8.1.250.0040.00428.09
8.1.240.0030.00624.03
8.1.230.0080.00419.23
8.1.220.0000.00917.77
8.1.210.0080.00018.77
8.1.200.0000.01017.48
8.1.190.0080.00017.64
8.1.180.0030.00618.70
8.1.170.0080.00018.71
8.1.160.0040.00422.20
8.1.150.0050.00518.62
8.1.140.0030.00617.43
8.1.130.0030.00317.89
8.1.120.0040.00417.54
8.1.110.0030.00517.54
8.1.100.0040.00417.53
8.1.90.0100.00017.51
8.1.80.0040.00417.40
8.1.70.0030.00317.37
8.1.60.0060.00317.62
8.1.50.0000.00717.55
8.1.40.0000.00817.55
8.1.30.0090.00017.58
8.1.20.0040.00417.50
8.1.10.0040.00417.59
8.1.00.0000.00917.42
8.0.300.0000.00718.77
8.0.290.0040.00417.27
8.0.280.0050.00318.53
8.0.270.0070.00017.38
8.0.260.0030.00316.89
8.0.250.0070.00017.06
8.0.240.0030.00717.13
8.0.230.0040.00417.08
8.0.220.0040.00416.93
8.0.210.0030.00517.07
8.0.200.0000.00716.99
8.0.190.0040.00417.09
8.0.180.0030.00517.11
8.0.170.0000.00917.05
8.0.160.0030.00616.97
8.0.150.0030.00617.04
8.0.140.0040.00417.00
8.0.130.0000.00613.49
8.0.120.0000.00716.95
8.0.110.0070.00016.95
8.0.100.0070.00016.98
8.0.90.0040.00416.88
8.0.80.0030.01216.97
8.0.70.0040.00416.98
8.0.60.0040.00416.93
8.0.50.0050.00317.07
8.0.30.0150.00817.12
8.0.20.0090.00917.40
8.0.10.0040.00416.97
8.0.00.0140.00516.76
7.4.330.0040.00415.00
7.4.320.0060.00016.70
7.4.300.0000.00616.53
7.4.290.0040.00416.64
7.4.280.0050.00316.69
7.4.270.0030.00316.59
7.4.260.0040.00416.58
7.4.250.0060.00316.65
7.4.240.0040.00416.55
7.4.230.0040.00416.51
7.4.220.0030.01516.69
7.4.210.0020.01216.61
7.4.200.0000.00716.57
7.4.190.0070.00016.73
7.4.160.0040.01216.67
7.4.150.0140.00317.40
7.4.140.0090.01117.86
7.4.130.0140.00316.59
7.4.120.0100.00816.78
7.4.110.0120.01216.47
7.4.100.0150.00616.72
7.4.90.0150.00316.75
7.4.80.0090.01419.39
7.4.70.0110.00716.55
7.4.60.0120.01116.58
7.4.50.0080.00016.79
7.4.40.0070.00722.77
7.4.30.0070.01016.66
7.4.00.0090.00814.90
7.3.330.0070.00013.49
7.3.320.0000.00513.39
7.3.310.0050.00316.30
7.3.300.0060.00016.41
7.3.290.0090.00916.43
7.3.280.0110.00816.48
7.3.270.0130.00417.40
7.3.260.0060.01216.58
7.3.250.0100.00816.61
7.3.240.0160.00316.64
7.3.230.0160.00016.41
7.3.210.0040.01216.60
7.3.200.0180.00019.39
7.3.190.0140.00316.45
7.3.180.0140.00416.48
7.3.170.0130.00316.54
7.3.160.0080.00816.55
7.3.120.0080.01014.71
7.3.110.0000.01914.88
7.3.100.0110.00715.10
7.3.90.0090.00615.03
7.3.80.0030.01114.72
7.3.70.0090.00014.88
7.3.60.0040.01214.96
7.3.50.0040.01115.00
7.3.40.0000.01414.65
7.3.30.0090.00614.77
7.3.20.0000.01516.43
7.3.10.0110.00616.28
7.3.00.0110.00816.48
7.2.330.0090.00916.79
7.2.320.0070.01416.85
7.2.310.0170.00016.87
7.2.300.0090.00816.40
7.2.290.0030.01316.84
7.2.250.0030.01615.27
7.2.240.0030.01314.89
7.2.230.0030.01014.98
7.2.220.0040.01415.03
7.2.210.0060.00315.00
7.2.200.0040.00415.15
7.2.190.0000.01514.70
7.2.180.0070.00715.04
7.2.170.0150.00014.97
7.2.160.0120.00415.16
7.2.150.0030.01316.48
7.2.140.0070.00716.88
7.2.130.0060.01116.49
7.2.120.0120.00416.75
7.2.110.0110.00316.76
7.2.100.0040.01216.50
7.2.90.0070.00916.91
7.2.80.0110.00816.68
7.2.70.0110.00516.48
7.2.60.0090.00716.75
7.2.50.0050.00916.90
7.2.40.0110.00516.79
7.2.30.0050.01116.72
7.2.20.0090.00616.69
7.2.10.0110.00616.70
7.2.00.0060.00916.74
7.1.330.0030.01315.75
7.1.320.0060.00815.84
7.1.310.0030.00815.55
7.1.300.0060.01015.37
7.1.290.0120.00315.88
7.1.280.0060.00615.75
7.1.270.0130.00315.55
7.1.260.0060.00615.64
7.1.250.0080.00715.61
7.1.240.0090.00315.75
7.1.230.0000.01015.43
7.1.220.0080.00415.71
7.1.210.0030.01015.73
7.1.200.0050.01015.83
7.1.190.0030.01015.82
7.1.180.0050.00815.54
7.1.170.0030.01215.45
7.1.160.0040.00815.51
7.1.150.0060.00615.49
7.1.140.0070.01015.82
7.1.130.0060.01215.40
7.1.120.0080.00615.82
7.1.110.0040.00715.77
7.1.100.0030.01015.73
7.1.90.0000.01315.70
7.1.80.0040.01115.76
7.1.70.0060.00516.48
7.1.60.0080.01217.72
7.1.50.0030.01516.30
7.1.40.0000.01615.35
7.1.30.0140.00315.87
7.1.20.0030.01015.77
7.1.10.0090.00315.64
7.1.00.0060.02019.03
7.0.330.0080.00614.89
7.0.320.0090.00014.96
7.0.310.0070.00315.26
7.0.300.0070.00715.08
7.0.290.0000.01115.37
7.0.280.0070.01115.29
7.0.270.0000.01115.06
7.0.260.0030.00915.36
7.0.250.0060.00315.41
7.0.240.0070.00715.24
7.0.230.0070.00715.40
7.0.220.0030.01015.35
7.0.210.0030.01015.18
7.0.200.0030.00816.07
7.0.190.0040.00815.33
7.0.180.0030.00715.26
7.0.170.0040.01115.44
7.0.160.0030.01415.39
7.0.150.0030.01015.22
7.0.140.0020.04218.65
7.0.130.0030.01015.41
7.0.120.0070.01015.53
7.0.110.0090.00415.14
7.0.100.0060.00615.41
7.0.90.0100.00315.43
7.0.80.0060.00915.36
7.0.70.1640.02017.84
7.0.60.0020.04817.71
7.0.50.0030.02516.81
7.0.40.0050.02516.81
7.0.30.0130.04316.79
7.0.20.0150.04516.72
7.0.10.0080.03116.71
7.0.00.0090.03716.62
5.6.400.0030.01014.16
5.6.390.0060.01013.86
5.6.380.0070.00713.97
5.6.370.0090.00614.11
5.6.360.0000.01114.49
5.6.350.0000.01114.52
5.6.340.0060.01214.30
5.6.330.0000.01614.52
5.6.320.0060.00314.42
5.6.310.0080.00514.25
5.6.300.0000.01214.54
5.6.290.0030.00614.13
5.6.280.0060.04017.83
5.6.270.0070.00714.32
5.6.260.0000.00914.25
5.6.250.0070.00714.43
5.6.240.0080.00814.23
5.6.230.0060.00614.17
5.6.220.0090.00914.45
5.6.210.0050.03017.53
5.6.200.0050.04916.39
5.6.190.0070.04417.42
5.6.180.0220.03217.23
5.6.170.0150.02917.29
5.6.160.0080.02717.30
5.6.150.0100.04116.14
5.6.140.0060.03616.36
5.6.130.0080.03716.46
5.6.120.0080.03117.65
5.6.110.0030.03617.70
5.6.100.0090.03717.70
5.6.90.0020.02917.80
5.6.80.0080.04217.36
5.6.70.0160.03917.34
5.6.60.0030.01014.13
5.6.50.0060.00314.48
5.6.40.0080.00814.15
5.6.30.0040.01414.28
5.6.20.0040.00814.34
5.6.10.0040.00814.01
5.6.00.0080.00814.08
5.5.380.0000.01414.25
5.5.370.0150.00314.36
5.5.360.0060.01014.25
5.5.350.0180.03817.19
5.5.340.0050.04016.05
5.5.330.0070.03917.46
5.5.320.0020.03717.43
5.5.310.0170.04117.21
5.5.300.0060.03016.04
5.5.290.0020.02516.15
5.5.280.0080.04417.61
5.5.270.0030.03417.59
5.5.260.0070.03617.49
5.5.250.0090.03317.53
5.5.240.0050.03017.13
5.5.230.0090.00614.00
5.5.220.0090.00314.18
5.5.210.0030.01014.43
5.5.200.0090.00613.91
5.5.190.0040.00814.34
5.5.180.0000.01514.06
5.5.170.0030.01014.15
5.5.160.0040.01114.03
5.5.150.0000.01313.83
5.5.140.0080.00313.89
5.5.130.0000.01214.32
5.5.120.0070.00714.35
5.5.110.0040.01214.49
5.5.100.0030.01314.10
5.5.90.0030.01214.15
5.5.80.0000.01014.17
5.5.70.0030.00614.23
5.5.60.0030.00714.00
5.5.50.0110.00414.12
5.5.40.0040.00814.10
5.5.30.0070.01114.07
5.5.20.0140.00714.33
5.5.10.0080.00413.97
5.5.00.0070.00714.40
5.4.450.0320.03316.03
5.4.440.0480.03915.88
5.4.430.0460.03215.87
5.4.420.0500.03216.00
5.4.410.0430.04215.81
5.4.400.0350.03415.80
5.4.390.0060.03015.80
5.4.380.0170.02615.64
5.4.370.0300.03315.47
5.4.360.0180.03015.59
5.4.350.0050.02212.25
5.4.340.0060.02112.25
5.4.330.0030.00612.45
5.4.320.0050.03012.49
5.4.310.0100.02412.49
5.4.300.0060.02212.49
5.4.290.0070.02112.49
5.4.280.0070.02112.44
5.4.270.0060.02712.44
5.4.260.0100.04215.59
5.4.250.0050.03715.73
5.4.240.0020.03515.71
5.4.230.0090.02715.55
5.4.220.0080.03015.70
5.4.210.0070.02915.67
5.4.200.0050.03715.72
5.4.190.0090.03015.68
5.4.180.0050.03215.59
5.4.170.0090.02715.76
5.4.160.0120.03715.71
5.4.150.0130.03515.63
5.4.140.0060.02814.45
5.4.130.0080.03214.43
5.4.120.0030.03714.52
5.4.110.0050.03514.46
5.4.100.0100.02514.42
5.4.90.0150.02314.49
5.4.80.0070.03214.44
5.4.70.0070.03014.50
5.4.60.0050.03614.44
5.4.50.0150.03314.43
5.4.40.0040.03614.39
5.4.30.0070.03714.42
5.4.20.0090.03714.40
5.4.10.0120.02714.39
5.4.00.0100.03014.20
5.3.290.0080.02212.63
5.3.280.0050.03313.46
5.3.270.0150.02713.55
5.3.260.0050.03113.59
5.3.250.0080.03913.59
5.3.240.0080.03013.59
5.3.230.0080.03213.58
5.3.220.0070.04013.48
5.3.210.0030.04113.56
5.3.200.0080.03013.52
5.3.190.0070.02913.62
5.3.180.0060.03013.52
5.3.170.0090.02813.52
5.3.160.0080.03513.52
5.3.150.0070.03013.52
5.3.140.0060.03713.63
5.3.130.0050.03313.56
5.3.120.0100.02613.61
5.3.110.0050.03513.56
5.3.100.0050.02913.35
5.3.90.0050.03013.33
5.3.80.0070.03413.26
5.3.70.0100.03013.24
5.3.60.0070.03713.33
5.3.50.0070.02913.22
5.3.40.0070.03513.26
5.3.30.0120.03713.18
5.3.20.0070.03813.13
5.3.10.0030.03312.98
5.3.00.0100.03313.10
5.2.170.0300.03711.02
5.2.160.0070.06011.27
5.2.150.0100.05711.35
5.2.140.0100.04711.09
5.2.130.0000.05011.23
5.2.120.0170.04711.14
5.2.110.0070.04011.32
5.2.100.0130.04711.32
5.2.90.0200.03311.05
5.2.80.0130.04011.31
5.2.70.0130.03711.13
5.2.60.0000.06011.32
5.2.50.0070.04311.15
5.2.40.0100.04311.22
5.2.30.0130.04311.00
5.2.20.0100.05311.09
5.2.10.0070.04710.86
5.2.00.0100.05710.85
5.1.60.0130.03710.02
5.1.50.0100.03310.24
5.1.40.0030.05010.02
5.1.30.0130.04710.36
5.1.20.0030.04010.23
5.1.10.0100.0309.96
5.1.00.0100.04310.18
5.0.50.0030.0338.43
5.0.40.0130.0338.43
5.0.30.0000.0438.20
5.0.20.0070.0278.29
5.0.10.0070.0278.14
5.0.00.0000.0478.18
4.4.90.0070.0207.27
4.4.80.0070.0207.27
4.4.70.0030.0237.27
4.4.60.0070.0277.27
4.4.50.0000.0337.27
4.4.40.0000.0377.27
4.4.30.0070.0207.27
4.4.20.0000.0337.27
4.4.10.0000.0307.27
4.4.00.0030.0307.27
4.3.110.0030.0277.27
4.3.100.0100.0207.27
4.3.90.0030.0207.27
4.3.80.0000.0377.27
4.3.70.0070.0277.27
4.3.60.0000.0237.27
4.3.50.0070.0207.27
4.3.40.0030.0407.27
4.3.30.0100.0237.27
4.3.20.0000.0307.27
4.3.10.0100.0277.27
4.3.00.0070.0237.29

preferences:
47.46 ms | 401 KiB | 5 Q