3v4l.org

run code in 300+ PHP versions simultaneously
<?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(); ?>
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
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.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 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

preferences:
239.81 ms | 402 KiB | 230 Q