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 . "\n"; } public function close() { $this->messages[] = 'close' . "\n"; } public function read($id) { $this->messages[] = 'read ' . $id . "\n"; } public function write($id, $data) { $this->messages[] = 'write ' . $id . ': ' . $data . "\n"; } public function destroy($id) { $this->messages[] = 'destroy ' . $id . "\n"; } public function gc($maxlifetime) { $this->messages[] = 'gc ' . $maxlifetime . "\n"; } } $handler = new MySessionHandler(); session_set_save_handler($handler, true); session_start(); $_SESSION['foo'] = 'bar'; $handler->messages[] = session_id() . "\n"; session_regenerate_id(); $handler->messages[] = session_id() . "\n"; session_destroy(); session_start(); session_write_close(); var_dump($handler->messages);
Output for git.master_jit, git.master, 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/nJ08J 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/nJ08J 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/nJ08J 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/nJ08J 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/nJ08J 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/nJ08J on line 33 Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in /in/nJ08J on line 40 Warning: session_start(): Session cannot be started after headers have already been sent in /in/nJ08J on line 41 Warning: session_regenerate_id(): Session ID cannot be regenerated when there is no active session in /in/nJ08J on line 46 Warning: session_destroy(): Trying to destroy uninitialized session in /in/nJ08J on line 48 Warning: session_start(): Session cannot be started after headers have already been sent in /in/nJ08J on line 50 array(2) { [0]=> string(1) " " [1]=> string(1) " " }

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