3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $pdo = new pdo( 'sqlite::memory:', null, null, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_GROUP | PDO::FETCH_FUNC ] ); $pdo->exec('create table x(sort int, foo text, bar text)'); $pdo->exec("insert into x(sort, foo, bar) values (1, 'a', 'b'), (1, 'c', 'd'), (2, 'e', 'f')"); $pdo->query('select * from x') ->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_FUNC, function () { var_dump(func_get_args()); });
based on etHAD
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } array(2) { [0]=> string(1) "c" [1]=> string(1) "d" } array(2) { [0]=> string(1) "e" [1]=> string(1) "f" }
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Object of class Closure$;4 could not be converted to string in /in/5igrt:-1 Stack trace: #0 /in/5igrt(-1): PDOStatement->fetchAll() #1 {main}
Process exited with code 255.
Output for hhvm-3.21.3
Fatal error: Uncaught Error: Object of class Closure$;4 could not be converted to string in /in/5igrt:17 Stack trace: #0 /in/5igrt(17): PDOStatement->fetchAll() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5
Fatal error: Uncaught exception 'Exception' with message '__construct() expects parameter 2 to be string, null given' in /in/5igrt:12 Stack trace: #0 /in/5igrt(12): PDO->__construct() #1 {main}
Process exited with code 255.