3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); namespace at\PDOi; use PDO as BasePDO, PDOStatement; $pdo = new PDO('sqlite::memory:'); [$markers, $values] = $pdo->arrayParam(['a', 'b', 'c']); $stmt = $pdo->prepare("select 'a' IN ({$markers})"); $stmt->execute($values); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); [$markers, $values] = $pdo->arrayParam(['a', 'b', 'c'], 'letters'); $stmt = $pdo->prepare("select 'a' IN ({$markers})"); $stmt->execute($values); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); /** * @package at.pdoi * @author Adrian <adrian@enspi.red> * @copyright 2014 - 2017 * @license GPL-3.0 (only) * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License, version 3. * The right to apply the terms of later versions of the GPL is RESERVED. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program. * If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>. */ /** * minor changes and additions to enhance PDO's security and convenience. */ class PDO extends BasePDO { /** * {@inheritDoc} * @see http://php.net/PDO.__construct * * adds good default options. */ public function __construct($dsn, $username = null, $password = null, $options = []) { $options += [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false ]; parent::__construct($dsn, $username, $password, $options); } /** * expands arrays into multiple named or positional parameters. * * @param array $values the values to parameterize * @param string $name name for named parameters (omit for positional parameters) * @return array { * @type string $0 comma-separated parameter markers (sql fragment) * @type array $1 parameter values, as a map or ordered list * } */ public function arrayParam(array $values, string $name = null) { $values = array_values($values); $i = 0; $keys = array_map( function ($value) use ($name, &$i) { $marker = $name ? ":{$name}_{$i}" : '?'; $i++; return $marker; }, $values ); if ($name) { $values = array_combine($keys, $values); } return [implode(', ', $keys), $values]; } /** * prepares and executes a statement in one step. * * @param string $sql the sql statement to prepare * @param array $params parameter values to execute against the statement * @return PDOStatement the executed statement object on success */ public function preparedQuery(string $sql, array $params = []) : PDOStatement { $stmt = $this->prepare($sql); $stmt->execute($params); return $stmt; } }

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.01019.18
8.3.50.0070.00717.50
8.3.40.0080.01119.97
8.3.30.0060.01019.86
8.3.20.0030.00622.77
8.3.10.0040.00422.64
8.3.00.0080.00018.87
8.2.180.0080.00825.92
8.2.170.0070.00719.68
8.2.160.0040.01122.02
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00422.84
8.2.120.0090.00026.35
8.2.110.0060.00323.13
8.2.100.0060.00618.78
8.2.90.0090.00018.91
8.2.80.0030.00620.16
8.2.70.0050.00319.04
8.2.60.0040.00419.03
8.2.50.0060.00318.38
8.2.40.0060.00321.30
8.2.30.0030.00621.34
8.2.20.0060.00318.88
8.2.10.0030.00518.99
8.2.00.0030.00618.94
8.1.280.0100.00725.92
8.1.270.0050.00323.99
8.1.260.0030.00526.35
8.1.250.0030.00628.09
8.1.240.0090.00023.41
8.1.230.0050.00521.79
8.1.220.0000.00818.53
8.1.210.0060.00319.53
8.1.200.0030.00618.10
8.1.190.0030.00618.23
8.1.180.0030.00518.39
8.1.170.0040.00419.59
8.1.160.0040.00419.78
8.1.150.0040.00421.10
8.1.140.0000.00820.48
8.1.130.0000.00719.87
8.1.120.0030.00618.43
8.1.110.0000.00818.36
8.1.100.0080.00018.34
8.1.90.0000.00818.26
8.1.80.0070.00018.36
8.1.70.0050.00318.39
8.1.60.0040.00418.57
8.1.50.0080.00018.37
8.1.40.0060.00318.47
8.1.30.0000.00918.60
8.1.20.0030.00518.62
8.1.10.0060.00318.55
8.1.00.0040.00418.48
8.0.300.0000.00720.82
8.0.290.0000.00817.75
8.0.280.0030.00519.39
8.0.270.0050.00318.27
8.0.260.0000.00717.86
8.0.250.0070.00017.98
8.0.240.0000.00817.88
8.0.230.0080.00017.95
8.0.220.0070.00017.82
8.0.210.0040.00417.93
8.0.200.0000.00717.94
8.0.190.0000.00917.89
8.0.180.0000.00817.91
8.0.170.0040.00717.93
8.0.160.0080.00017.90
8.0.150.0000.00717.78
8.0.140.0040.00417.79
8.0.130.0000.00614.23
8.0.120.0030.00617.72
8.0.110.0080.00017.96
8.0.100.0070.00017.88
8.0.90.0000.00717.75
8.0.80.0060.01317.79
8.0.70.0050.00317.66
8.0.60.0030.00617.67
8.0.50.0040.00417.97
8.0.30.0120.00817.93
8.0.20.0130.00917.95
8.0.10.0000.00818.04
8.0.00.0110.00717.82
7.4.330.0060.00015.98
7.4.320.0030.00517.26
7.4.300.0000.00717.38
7.4.290.0080.00317.50
7.4.280.0000.00817.47
7.4.270.0000.00717.45
7.4.260.0090.00317.51
7.4.250.0040.00417.50
7.4.240.0040.00417.50
7.4.230.0050.00317.32
7.4.220.0070.01717.31
7.4.210.0100.01017.58
7.4.200.0070.00017.48
7.4.160.0080.00817.38
7.4.150.0070.01117.43
7.4.140.0120.00917.86
7.4.130.0100.01017.23
7.4.120.0100.01217.32
7.4.110.0030.01417.20
7.4.100.0160.00617.62
7.4.90.0030.01817.48
7.4.80.0180.00919.39
7.4.70.0100.00717.42
7.4.60.0130.00317.34
7.4.50.0000.01717.30
7.4.40.0130.00317.51
7.4.30.0160.00317.37
7.4.00.0060.00915.72
7.3.330.0040.00413.99
7.3.320.0000.00514.17
7.3.310.0040.00417.14
7.3.300.0030.00317.11
7.3.290.0110.00417.26
7.3.280.0090.00817.23
7.3.270.0110.00617.40
7.3.260.0110.00917.43
7.3.250.0160.00617.39
7.3.240.0120.00517.23
7.3.230.0060.01417.38
7.3.210.0080.01517.25
7.3.200.0120.00617.22
7.3.190.0140.00617.24
7.3.180.0080.01417.46
7.3.170.0060.01017.39
7.3.160.0080.00917.35
7.3.120.0060.00615.67
7.3.110.0070.00415.81
7.3.100.0090.00415.54
7.3.90.0100.00715.68
7.3.80.0080.00515.56
7.3.70.0080.00815.66
7.3.60.0080.00615.66
7.3.50.0120.00415.49
7.3.40.0080.00815.36
7.3.30.0030.01015.63
7.3.20.0040.01117.28
7.3.10.0030.01317.47
7.3.00.0040.01217.34
7.2.330.0110.00717.34
7.2.320.0060.01217.50
7.2.310.0150.00317.56
7.2.300.0150.00917.51
7.2.290.0060.01517.68
7.2.250.0060.00916.13
7.2.240.0060.00715.70
7.2.230.0100.00716.02
7.2.220.0130.00616.11
7.2.210.0070.01015.63
7.2.200.0090.00615.84
7.2.190.0140.00315.82
7.2.180.0080.00815.86
7.2.170.0060.00915.80
7.2.160.0000.01515.74
7.2.150.0000.01817.72
7.2.140.0050.00817.78
7.2.130.0070.00717.50
7.2.120.0060.00917.71
7.2.110.0140.00417.57
7.2.100.0030.01017.45
7.2.90.0030.01217.89
7.2.80.0100.00617.41
7.2.70.0030.01417.80
7.2.60.0080.00617.71
7.2.50.0040.00917.71
7.2.40.0100.01017.61
7.2.30.0070.00717.61
7.2.20.0030.01217.67
7.2.10.0030.00717.66
7.2.00.0070.01017.60
7.1.330.0030.00616.50
7.1.320.0070.01016.70
7.1.310.0140.00316.45
7.1.300.0120.00416.82
7.1.290.0030.01316.96
7.1.280.0120.00616.81
7.1.270.0030.01216.90
7.1.260.0040.01116.80
7.1.250.0040.01116.77
7.1.240.0090.00916.61
7.1.230.0000.01716.74
7.1.220.0090.00616.95
7.1.210.0130.00616.67
7.1.200.0100.00216.61
7.1.190.0090.00616.59
7.1.180.0090.00316.86
7.1.170.0060.00616.89
7.1.160.0100.00616.96
7.1.150.0070.01017.07
7.1.140.0070.00716.73
7.1.130.0040.01116.62
7.1.120.0100.01016.82
7.1.110.0090.00616.93
7.1.100.0100.00316.67
7.1.90.0050.01016.77
7.1.80.0090.00616.85
7.1.70.0070.00617.48
7.1.60.0280.01325.59
7.1.50.0250.01325.36
7.1.40.0590.00725.15
7.1.30.0370.01225.36
7.1.20.0500.01125.38
7.1.10.0260.00616.32
7.1.00.0310.00516.31
7.0.330.0090.00615.06
7.0.320.0150.00015.05
7.0.310.0030.01315.18
7.0.300.0030.01315.14
7.0.290.0050.00315.16
7.0.280.0030.00615.07
7.0.270.0000.00915.24
7.0.260.0070.00715.12
7.0.250.0080.00415.24
7.0.240.0050.00515.18
7.0.230.0060.00615.09
7.0.220.0070.00715.05
7.0.210.0000.01415.10
7.0.200.0220.01014.82
7.0.190.0280.00814.90
7.0.180.0340.01014.68
7.0.170.0280.01214.63
7.0.160.0280.00714.69
7.0.150.0210.01114.67
7.0.140.0260.00514.68
7.0.130.0290.00714.83
7.0.120.0420.01114.87
7.0.110.0270.00614.79
7.0.100.0270.00914.67
7.0.90.0380.00814.67
7.0.80.0410.00514.67
7.0.70.0260.00514.73
7.0.60.0470.00314.83
7.0.50.0330.00314.91
7.0.40.0260.00713.85
7.0.30.0300.00513.91
7.0.20.0250.01013.80
7.0.10.0270.01013.85
7.0.00.0280.00613.93
5.6.400.0000.01313.93
5.6.390.0030.01014.17
5.6.380.0170.00013.64
5.6.370.0040.00414.30
5.6.360.0000.01314.17
5.6.350.0090.00314.20
5.6.340.0030.01014.16
5.6.330.0000.00913.82
5.6.320.0040.01514.26
5.6.310.0000.01114.22
5.6.300.0000.01414.07
5.6.290.0060.00613.98
5.6.280.0030.00614.36
5.6.270.0080.00514.22
5.6.260.0000.01314.17
5.6.250.0060.00614.11
5.6.240.0000.01414.09
5.6.230.0060.00614.16
5.6.220.0000.01414.31
5.6.210.0090.00613.84
5.6.200.0040.00414.21
5.6.190.0030.00714.24
5.6.180.0000.01214.14
5.6.170.0090.00314.12
5.6.160.0030.01014.16
5.6.150.0030.00914.43
5.6.140.0060.00613.82
5.6.130.0000.00814.20
5.6.120.0040.01014.16
5.6.110.0000.01114.11
5.6.100.0050.00514.01
5.6.90.0060.00614.00
5.6.80.0000.01414.07
5.6.70.0040.00413.95
5.6.60.0060.00614.20
5.6.50.0040.01113.93
5.6.40.0000.01313.99
5.6.30.0080.00413.94
5.6.20.0040.00813.91
5.6.10.0060.00613.97
5.6.00.0030.00913.92

preferences:
60.4 ms | 400 KiB | 5 Q