3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MySessionHandler implements \SessionHandlerInterface { public $messages = array(); public function open($savePath, $sessionName) { $this->messages[] = 'open ' . $sessionName; } public function close() { $this->messages[] = 'close'; } public function read($id) { $this->messages[] = 'read ' . $id; } public function write($id, $data) { $this->messages[] = 'write ' . $id . ': ' . $data; throw new \RuntimeException('bad'); } public function destroy($id) { $this->messages[] = 'destroy ' . $id; } public function gc($maxlifetime) { $this->messages[] = 'gc ' . var_export($maxlifetime, true); } public function __destruct() { var_dump($this->messages); } } $handler = new MySessionHandler(); session_set_save_handler($handler, true); $handler->messages[] = 'isset($_SESSION): ' . var_export(isset($_SESSION), true); $_SESSION['before'] = 'start'; session_start(); $_SESSION['foo'] = 'bar'; $handler->messages[] = 'current session_id: ' . session_id(); session_regenerate_id(true); $handler->messages[] = 'current session_id: ' . session_id(); try { session_write_close(); } catch (\Exception $e) { } session_start(); session_destroy(); $handler->messages[] = var_export($_SESSION, true); $handler->messages[] = 'current session_id: ' . var_export(session_id(), true); session_id('explicit-session-id'); session_start(); $_SESSION['john'] = 'doe';
Output for 7.1.0
Warning: session_start(): Session callback expects true/false return value in /in/eiTN8 on line 51 Warning: session_start(): Session callback expects true/false return value in /in/eiTN8 on line 51 Fatal error: session_start(): Failed to initialize storage module: user (path: ) in /in/eiTN8 on line 51
Process exited with code 255.
Output for 7.0.0 - 7.0.14
Warning: session_start(): Session callback expects true/false return value in /in/eiTN8 on line 51 Fatal error: session_start(): Failed to initialize storage module: user (path: ) in /in/eiTN8 on line 51 Warning: Unknown: Session callback expects true/false return value in Unknown on line 0
Process exited with code 255.
Output for 5.4.7 - 5.6.28
Fatal error: Uncaught exception 'RuntimeException' with message 'bad' in /in/eiTN8:26 Stack trace: #0 [internal function]: MySessionHandler->write('explicit-sessio...', 'john|s:3:"doe";') #1 [internal function]: session_write_close() #2 {main} thrown in /in/eiTN8 on line 26
Process exited with code 255.
Output for 5.4.0 - 5.4.6
Fatal error: Uncaught exception 'RuntimeException' with message 'bad' in /in/eiTN8:26 Stack trace: #0 [internal function]: MySessionHandler->write('explicit-sessio...', 'john|s:3:"doe";') #1 [internal function]: session_write_close() #2 {main} thrown in /in/eiTN8 on line 26
Output for 5.3.0 - 5.3.29
Fatal error: Interface 'SessionHandlerInterface' not found in /in/eiTN8 on line 5
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/eiTN8 on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/eiTN8 on line 26 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/eiTN8 on line 60 Fatal error: Interface 'SessionHandlerInterface' not found in /in/eiTN8 on line 4
Process exited with code 255.
Output for 5.0.5 - 5.2.2
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/eiTN8</b> on line <b>4</b><br /> <br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/eiTN8</b> on line <b>26</b><br /> <br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/eiTN8</b> on line <b>60</b><br /> <br /> <b>Fatal error</b>: Interface 'SessionHandlerInterface' not found in <b>/in/eiTN8</b> on line <b>4</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.4
<br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/eiTN8</b> on line <b>4</b><br /> <br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/eiTN8</b> on line <b>26</b><br /> <br /> <b>Warning</b>: Unexpected character in input: '\' (ASCII=92) state=1 in <b>/in/eiTN8</b> on line <b>60</b><br /> <br /> <b>Fatal error</b>: Class 'SessionHandlerInterface' not found in <b>/in/eiTN8</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting '{' in <b>/in/eiTN8</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting '{' in <b>/in/eiTN8</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `'{'' in <b>/in/eiTN8</b> on line <b>4</b><br />
Process exited with code 255.