3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Testing shutdown sequence function checkSqlite() { if (!$GLOBALS['pdo']) echo "PDO connection\n"; } $pdo = new PDO('sqlite:'); function shutdown() { checkSqlite(); echo "register_shutdown_function\n"; } register_shutdown_function('shutdown'); class MyClass { function __destruct() { checkSqlite(); echo "Object destructor\n"; } } function obcallback($buffer) { checkSqlite(); $buffer .= "Output buffer callback\n"; return $buffer; } ob_start('obcallback'); $myObject = new MyClass; function dummy() { return true; } function sessionclose() { checkSqlite(); echo "Session close\n"; return true; } function sessionwrite() { checkSqlite(); echo "Session write\n"; return true; } session_set_save_handler('dummy','sessionclose','dummy','sessionwrite','dummy','dummy'); session_start(); ?>
based on NSmTZ
Output for 7.1.0 - 7.2.0
Session close Warning: session_start(): Failed to read session data: user (path: ) in /in/83BAY on line 65 register_shutdown_function Object destructor Output buffer callback
Output for 5.3.21 - 7.0.20
register_shutdown_function Object destructor Output buffer callback Notice: Undefined index: pdo in /in/83BAY on line 7 PDO connection Session write Notice: Undefined index: pdo in /in/83BAY on line 7 PDO connection Session close