3v4l.org

run code in 300+ PHP versions simultaneously
<?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 { $insert->execute(); } catch (PDOException $e) { // assuming duplicate $n++; } } var_dump($db->query('select * from foo')->fetchAll(PDO::FETCH_ASSOC));
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(1) { ["n"]=> int(1) } [1]=> array(1) { ["n"]=> int(2) } [2]=> array(1) { ["n"]=> int(3) } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.64 ms | 401 KiB | 8 Q