3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); function countAfterHeader(\PDOStatement $stmt): int { if ($stmt->fetch() === false) { return 0; } $count = 0; while ($stmt->fetch() !== false) { $count++; } return $count; } $pdo = new PDO('sqlite::memory:'); $pdo->exec('CREATE TABLE t (id INTEGER)'); $pdo->exec('INSERT INTO t VALUES (1), (2), (3)'); var_dump(countAfterHeader($pdo->query('SELECT id FROM t'))); var_dump(countAfterHeader($pdo->query('SELECT id FROM t WHERE id > 3')));
Output for master
int(2) int(0)

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:
19.29 ms | 1163 KiB | 7 Q