3v4l.org

run code in 300+ PHP versions simultaneously
<?php //============================================== // class //============================================== abstract class PDOWrapper { //============================================== // variables //============================================== private $exception = Null; private $username = Null; private $password = Null; private $dsn = Null; private $client = Null; private $pdoStatement = Null; //============================================== // constructor //============================================== final public function __construct() { $this->reset(); } //============================================== // overrides //============================================== abstract protected function getConfigFile(); //============================================== // main //============================================== final public function prepare($query) { if ($this->ready()) { $this->pdoStatement = $this->client->prepare($query); } return $this->checkError(); } final public function execute() { if ($this->ready() && $this->pdoStatement) { return $this->pdoStatement->execute(); } return $this->checkError(); } final public function fetch() { if ($this->ready() && $this->pdoStatement) { return $this->pdoStatement->fetch(); } return False; } final public function fetchAll() { if ($this->ready() && $this->pdoStatement) { return $this->pdoStatement->fetchAll(); } return False; } final public function query($query) { if ($this->ready()) { $this->pdoStatement = $this->client->query($query); } return $this->checkError(); } final public function ready() { return !$this->hasException(); } final public function reset() { $exception = Null; try { $this->loadConfigFile($this->getConfigFile()); //may throw error (see __get()) $this->client = new PDO($this->dsn, $this->username, $this->password); } catch (Exception $e) { $this->exception = $e; } } //============================================== // accessing //============================================== final public function hasException() { return isset($this->exception); } final public function getException() { return $this->exception; } final public function getRowCount() { if ($this->pdoStatement && !empty($this->pdoStatement->errorInfo()[2])) { return $this->pdoStatement->rowCount(); } return False; } final protected function setException($e) { $this->exception = $e; } //============================================== // utility //============================================== final private function checkError() { //pdoStatement->errorInfo() always returns array if ($this->pdoStatement == False) { $this->exception = new PDOException('Connection Error - Please Check Config File and Network'); return False; } if (!empty($this->pdoStatement->errorInfo()[2])) { $msg = $this->client->errorInfo()[2]; $errCode = $this->client->errorCode(); $this->exception = new PDOException($msg, $code = $errCode); return False; } return True; } final private function loadConfigFile($filepath) { $string = @file_get_contents($filepath); if ($string === False) { throw new FileIOException($filepath); } $json = @json_decode($string, true); if ($json === False || !$json['USERNAME'] || !$json['PASSWORD'] || !$json['DSN']) { throw new InvalidFileFormatException($filepath . ' : ' . json_last_error_msg(), $code = json_last_error()); } $this->username = $json['USERNAME']; $this->password = $json['PASSWORD']; $this->dsn = $json['DSN']; } } $a = new PDOException("test", $code = 4); echo $a->getMessage();

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.0070.00718.30
8.3.50.0060.01321.26
8.3.40.0100.00618.96
8.3.30.0110.00418.82
8.3.20.0000.00720.16
8.3.10.0050.00321.81
8.3.00.0090.00021.89
8.2.180.0160.00616.63
8.2.170.0090.00622.96
8.2.160.0110.00420.52
8.2.150.0080.00024.18
8.2.140.0070.00024.66
8.2.130.0000.00821.07
8.2.120.0000.00826.35
8.2.110.0040.00419.32
8.2.100.0000.01118.04
8.2.90.0000.00819.09
8.2.80.0080.00017.97
8.2.70.0070.00317.63
8.2.60.0040.00417.91
8.2.50.0030.00618.09
8.2.40.0050.00322.20
8.2.30.0080.00019.39
8.2.20.0040.00417.79
8.2.10.0000.00818.12
8.2.00.0080.00018.10
8.1.280.0040.01525.92
8.1.270.0100.00022.05
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0070.00322.09
8.1.230.0080.00317.76
8.1.220.0000.00817.78
8.1.210.0090.00018.77
8.1.200.0030.00617.36
8.1.190.0060.00317.23
8.1.180.0080.00018.10
8.1.170.0060.00318.37
8.1.160.0040.00420.75
8.1.150.0110.00018.75
8.1.140.0040.00419.56
8.1.130.0040.00417.73
8.1.120.0000.00717.43
8.1.110.0000.00817.46
8.1.100.0050.00217.46
8.1.90.0000.00717.45
8.1.80.0030.00617.33
8.1.70.0000.00717.42
8.1.60.0060.00317.48
8.1.50.0000.00917.52
8.1.40.0040.00417.46
8.1.30.0000.00917.59
8.1.20.0000.00717.63
8.1.10.0040.00417.61
8.1.00.0030.00517.57
8.0.300.0000.00818.84
8.0.290.0040.00416.88
8.0.280.0030.00318.41
8.0.270.0000.00817.31
8.0.260.0050.00317.38
8.0.250.0030.00417.07
8.0.240.0040.00417.00
8.0.230.0030.00316.99
8.0.220.0030.00616.96
8.0.210.0030.00316.97
8.0.200.0060.00016.97
8.0.190.0000.00716.98
8.0.180.0040.00416.96
8.0.170.0050.00317.00
8.0.160.0040.00416.95
8.0.150.0000.00716.81
8.0.140.0040.00416.86
8.0.130.0060.00013.45
8.0.120.0000.00816.86
8.0.110.0090.00016.95
8.0.100.0000.00716.87
8.0.90.0040.00417.01
8.0.80.0130.00616.86
8.0.70.0020.00516.77
8.0.60.0040.00416.97
8.0.50.0050.00216.81
8.0.30.0080.01117.10
8.0.20.0090.01117.40
8.0.10.0040.00417.09
8.0.00.0070.01116.58
7.4.330.0050.00016.70
7.4.320.0000.00616.45
7.4.300.0070.00016.48
7.4.290.0030.00316.41
7.4.280.0080.00016.52
7.4.270.0030.00316.43
7.4.260.0040.00316.48
7.4.250.0040.00416.55
7.4.240.0040.00416.39
7.4.230.0000.00716.39
7.4.220.0100.00916.56
7.4.210.0070.00716.66
7.4.200.0040.00416.47
7.4.160.0100.00616.53
7.4.150.0160.00317.40
7.4.140.0090.00917.86
7.4.130.0110.01016.49
7.4.120.0080.01416.44
7.4.110.0070.01016.63
7.4.100.0070.01016.39
7.4.90.0060.01216.61
7.4.80.0140.00319.39
7.4.70.0180.00316.39
7.4.60.0040.01116.48
7.4.50.0070.01016.32
7.4.40.0120.00616.71
7.4.30.0000.01716.57
7.4.10.0100.01014.71
7.4.00.0060.01015.01
7.3.330.0030.00413.04
7.3.320.0000.00513.17
7.3.310.0040.00416.11
7.3.300.0040.00416.21
7.3.290.0120.00416.19
7.3.280.0120.00616.13
7.3.270.0160.01017.40
7.3.260.0070.01116.28
7.3.250.0160.00516.31
7.3.240.0060.01316.59
7.3.230.0080.00816.39
7.3.210.0040.01316.26
7.3.200.0210.00019.39
7.3.190.0090.00916.17
7.3.180.0030.01316.57
7.3.170.0060.01216.43
7.3.160.0080.00816.43
7.3.130.0040.01214.71
7.3.120.0080.00914.89
7.3.110.0070.01114.75
7.3.100.0030.01014.57
7.3.90.0020.00914.82
7.3.80.0050.00614.61
7.3.70.0080.00714.65
7.3.60.0070.00714.46
7.3.50.0080.00414.59
7.3.40.0080.00614.69
7.3.30.0030.00914.65
7.3.20.0060.00916.52
7.3.10.0050.01016.52
7.3.00.0060.00716.39
7.2.330.0060.01616.88
7.2.320.0100.01316.46
7.2.310.0130.00316.84
7.2.300.0110.00716.74
7.2.290.0040.01216.86
7.2.260.0080.00415.00
7.2.250.0080.00814.84
7.2.240.0090.00714.98
7.2.230.0050.01215.05
7.2.220.0080.00615.09
7.2.210.0050.00715.03
7.2.200.0060.00915.04
7.2.190.0040.01115.05
7.2.180.0040.01115.05
7.2.170.0070.00714.94
7.2.160.0080.00715.01
7.2.150.0050.01016.94
7.2.140.0020.01316.78
7.2.130.0030.00916.85
7.2.120.0070.00616.76
7.2.110.0050.00817.01
7.2.100.0060.01116.88
7.2.90.0080.00716.90
7.2.80.0080.00916.83
7.2.70.0070.00816.74
7.2.60.0040.00816.85
7.2.50.0060.00816.81
7.2.40.0050.00816.86
7.2.30.0080.00616.87
7.2.20.0010.01316.73
7.2.10.0060.00716.78
7.2.00.0060.00617.53
7.1.330.0040.00915.56
7.1.320.0070.00515.62
7.1.310.0070.00615.62
7.1.300.0030.01215.68
7.1.290.0030.00715.63
7.1.280.0060.00815.61
7.1.270.0070.00715.33
7.1.260.0070.00515.71
7.1.250.0090.00315.47
7.1.240.0110.00415.46
7.1.230.0000.01415.67
7.1.220.0040.01115.53
7.1.210.0090.00615.74
7.1.200.0040.00715.52
7.1.190.0040.00415.82
7.1.180.0030.01315.33
7.1.170.0000.01315.66
7.1.160.0100.00315.58
7.1.150.0030.01015.34
7.1.140.0030.01315.59
7.1.130.0090.00315.46
7.1.120.0090.00915.61
7.1.110.0090.00615.69
7.1.100.0050.00916.69
7.1.90.0040.00415.57
7.1.80.0090.00615.67
7.1.70.0080.00416.15
7.1.60.0030.01517.51
7.1.50.0050.00816.30
7.1.40.0060.00915.60
7.1.30.0030.01215.69
7.1.20.0070.01015.75
7.1.10.0090.00615.83
7.1.00.0070.04019.06
7.0.330.0040.00815.36
7.0.320.0130.00015.32
7.0.310.0100.00014.99
7.0.300.0030.01015.48
7.0.290.0060.00615.00
7.0.280.0040.01115.23
7.0.270.0110.00615.35
7.0.260.0100.00315.30
7.0.250.0040.00815.35
7.0.240.0030.01015.46
7.0.230.0030.00615.35
7.0.220.0070.00615.48
7.0.210.0040.00415.37
7.0.200.0090.00414.95
7.0.190.0030.00615.42
7.0.180.0070.00715.39
7.0.170.0130.00015.49
7.0.160.0070.00715.14
7.0.150.0000.01715.09
7.0.140.0110.00415.07
7.0.130.0040.00415.56
7.0.120.0060.01015.46
7.0.110.0030.01015.19
7.0.100.0080.00515.41
7.0.90.0100.00315.17
7.0.80.0090.00615.35
7.0.70.0030.01015.51
7.0.60.0080.04818.52
7.0.50.0020.05216.65
7.0.40.0110.03016.80
7.0.30.0080.03016.73
7.0.20.0120.02916.79
7.0.10.0040.02716.85
7.0.00.0100.04216.79
5.6.400.0140.00314.41
5.6.390.0030.01014.23
5.6.380.0030.01014.32
5.6.370.0110.00414.29
5.6.360.0030.01014.17
5.6.350.0030.00614.46
5.6.340.0120.00614.24
5.6.330.0090.00614.38
5.6.320.0030.01014.66
5.6.310.0030.00914.27
5.6.300.0060.00914.67
5.6.290.0040.00814.64
5.6.280.0040.02317.87
5.6.270.0040.00414.27
5.6.260.0060.00614.14
5.6.250.0080.00814.72
5.6.240.0070.00714.29
5.6.230.0120.00414.38
5.6.220.0000.01314.18
5.6.210.0050.03217.59
5.6.200.0050.02816.10
5.6.190.0050.02517.44
5.6.180.0180.04317.39
5.6.170.0340.03317.32
5.6.160.0030.02917.36
5.6.150.0050.03516.40
5.6.140.0050.02716.27
5.6.130.0030.04516.16
5.6.120.0050.02217.54
5.6.110.0030.02717.67
5.6.100.0020.05417.60
5.6.90.0070.02317.59
5.6.80.0100.04517.28
5.6.70.0000.01514.08
5.6.60.0040.01514.16
5.6.50.0000.01014.34
5.6.40.0070.00714.34
5.6.30.0050.00414.29
5.6.20.0060.01014.32
5.6.10.0040.01114.19
5.6.00.0070.01114.31
5.5.380.0040.00813.99
5.5.370.0090.00614.05
5.5.360.0070.00714.20
5.5.350.0150.02717.30
5.5.340.0070.03916.19
5.5.330.0050.04717.28
5.5.320.0200.03817.30
5.5.310.0110.02817.37
5.5.300.0060.02316.36
5.5.290.0070.04216.11
5.5.280.0050.04117.67
5.5.270.0030.03317.41
5.5.260.0120.03117.75
5.5.250.0080.03817.48
5.5.240.0010.04617.26
5.5.230.0060.00614.09
5.5.220.0000.01814.27
5.5.210.0000.01114.05
5.5.200.0110.00013.89
5.5.190.0060.00314.40
5.5.180.0080.00314.40
5.5.170.0060.01314.23
5.5.160.0040.01514.33
5.5.150.0000.01814.15
5.5.140.0000.00814.30
5.5.130.0070.00714.00
5.5.120.0000.01414.25
5.5.110.0060.00614.39
5.5.100.0000.01614.46
5.5.90.0110.00614.31
5.5.80.0030.00514.11
5.5.70.0030.00614.21
5.5.60.0000.01414.27
5.5.50.0040.00814.04
5.5.40.0000.01113.79
5.5.30.0040.00814.18
5.5.20.0070.00314.37
5.5.10.0000.01414.26
5.5.00.0090.00314.29

preferences:
48.3 ms | 401 KiB | 5 Q