3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pdo = new pdo('sqlite::memory:', null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,PDO::ATTR_EMULATE_PREPARES => false]); $pdo->exec('create table test1 (id int, name text)'); $pdo->exec("insert into test1(id, name) values (1, 'abc'), (2, 'def')"); $stmt = $pdo->prepare('SELECT * FROM test1 WHERE id = :id AND name = :name'); var_dump($stmt->execute(['name' => 'abc', 'id' => 1])); foreach ($stmt as $row) { print_r($row); } echo "\n-----\n"; var_dump($stmt->execute(['name' => 'abc', 1])); foreach ($stmt as $row) { print_r($row); } echo "\n-----\n"; var_dump($stmt->execute(['name' => 'abc', 2])); foreach ($stmt as $row) { print_r($row); } echo "\n-----\n";
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.30, 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
bool(true) Array ( [id] => 1 [0] => 1 [name] => abc [1] => abc ) ----- bool(true) Array ( [id] => 1 [0] => 1 [name] => abc [1] => abc ) ----- bool(true) -----

preferences:
50.72 ms | 410 KiB | 5 Q