3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } 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(); $handler->messages[] = 'session_status(): ' . session_status(); 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(); session_write_close(); $handler->messages[] = '$_SESSION after close: ' . var_export($_SESSION, true); $handler->messages[] = 'session_id after close: ' . session_id(); session_start(); session_destroy(); $handler->messages[] = '$_SESSION after destroy: ' . var_export($_SESSION, true); $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 git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MySessionHandler::open($savePath, $sessionName) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ol3GF on line 8 Deprecated: Return type of MySessionHandler::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ol3GF on line 13 Deprecated: Return type of MySessionHandler::read($id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ol3GF on line 18 Deprecated: Return type of MySessionHandler::write($id, $data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ol3GF on line 23 Deprecated: Return type of MySessionHandler::destroy($id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ol3GF on line 28 Deprecated: Return type of MySessionHandler::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ol3GF on line 33 Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in /in/ol3GF on line 47 Warning: session_start(): Session cannot be started after headers have already been sent in /in/ol3GF on line 52 Warning: session_regenerate_id(): Session ID cannot be regenerated when there is no active session in /in/ol3GF on line 57 Warning: session_start(): Session cannot be started after headers have already been sent in /in/ol3GF on line 64 Warning: session_destroy(): Trying to destroy uninitialized session in /in/ol3GF on line 65 Warning: session_id(): Session ID cannot be changed after headers have already been sent in /in/ol3GF on line 71 Warning: session_start(): Session cannot be started after headers have already been sent in /in/ol3GF on line 72 array(9) { [0]=> string(19) "session_status(): 1" [1]=> string(23) "isset($_SESSION): false" [2]=> string(20) "current session_id: " [3]=> string(20) "current session_id: " [4]=> string(73) "$_SESSION after close: array ( 'before' => 'start', 'foo' => 'bar', )" [5]=> string(24) "session_id after close: " [6]=> string(75) "$_SESSION after destroy: array ( 'before' => 'start', 'foo' => 'bar', )" [7]=> string(50) "array ( 'before' => 'start', 'foo' => 'bar', )" [8]=> string(22) "current session_id: ''" }

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:
35.17 ms | 409 KiB | 8 Q