3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $db = new pdo('sqlite::memory:', null, null, [PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]); $db->exec('create table foo( n INT UNIQUE );'); $n = 1; $insert = $db->prepare('insert into foo(n) values(:n)'); $insert->bindParam('n', $n); for ($i=0; $i<5; $i++) { try { $db->exec(); } catch (PDOException $e) { // assiming duplicate $n++; } }
based on YULBd
Output for 5.6.0 - 7.3.0alpha1
Warning: PDO::exec() expects exactly 1 parameter, 0 given in /in/df7gX on line 13 Warning: PDO::exec() expects exactly 1 parameter, 0 given in /in/df7gX on line 13 Warning: PDO::exec() expects exactly 1 parameter, 0 given in /in/df7gX on line 13 Warning: PDO::exec() expects exactly 1 parameter, 0 given in /in/df7gX on line 13 Warning: PDO::exec() expects exactly 1 parameter, 0 given in /in/df7gX on line 13