3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DemoBugSessionHandler implements SessionHandlerInterface { public function open($save_path, $name) { return true; } /** * Read session data * @link https://php.net/manual/en/sessionhandlerinterface.read.php * @param string $session_id The session id to read data for. * @return string <p> * Returns an encoded string of the read data. * If nothing was read, it must return an empty string. * Note this value is returned internally to PHP for processing. * </p> * @since 5.4.0 */ public function read($session_id) { // Simulate a session ID regeneration. \session_id('newsessionid'); return ''; } /** * Write session data * @link https://php.net/manual/en/sessionhandlerinterface.write.php * @param string $session_id The session id. * @param string $session_data <p> * The encoded session data. This data is the * result of the PHP internally encoding * the $_SESSION superglobal to a serialized * string and passing it as this parameter. * Please note sessions use an alternative serialization method. * </p> * @return bool <p> * The return value (usually TRUE on success, FALSE on failure). * Note this value is returned internally to PHP for processing. * </p> * @since 5.4.0 */ public function write($session_id, $session_data) { // Print back to the user agent the $session_id // that is going to be persisted when the script finishes. echo $session_id . PHP_EOL; return true; } public function destroy($session_id) { return true; } public function close() { return true; } public function gc($maxlifetime) { return true; } } ini_set('session.use_strict_mode', '1'); session_set_save_handler(new \DemoBugSessionHandler(), true); session_start(); echo ini_get('session.use_strict_mode') . PHP_EOL;
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Return type of DemoBugSessionHandler::open($save_path, $name) 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/pfKge on line 5 Deprecated: Return type of DemoBugSessionHandler::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/pfKge on line 61 Deprecated: Return type of DemoBugSessionHandler::read($session_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/pfKge on line 21 Deprecated: Return type of DemoBugSessionHandler::write($session_id, $session_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/pfKge on line 46 Deprecated: Return type of DemoBugSessionHandler::destroy($session_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/pfKge on line 56 Deprecated: Return type of DemoBugSessionHandler::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/pfKge on line 66 Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in /in/pfKge on line 72 Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in /in/pfKge on line 74 Warning: session_start(): Session cannot be started after headers have already been sent in /in/pfKge on line 76 0
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Return type of DemoBugSessionHandler::open($save_path, $name) 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/pfKge on line 5 Deprecated: Return type of DemoBugSessionHandler::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/pfKge on line 61 Deprecated: Return type of DemoBugSessionHandler::read($session_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/pfKge on line 21 Deprecated: Return type of DemoBugSessionHandler::write($session_id, $session_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/pfKge on line 46 Deprecated: Return type of DemoBugSessionHandler::destroy($session_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/pfKge on line 56 Deprecated: Return type of DemoBugSessionHandler::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/pfKge on line 66 Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in /in/pfKge on line 72 Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in /in/pfKge on line 74 Warning: session_start(): Session cannot be started after headers have already been sent in /in/pfKge on line 76 0
Output for 8.0.0 - 8.0.30
Warning: session_id(): Session ID cannot be changed when a session is active in /in/pfKge on line 24 Warning: session_start(): Session cache limiter cannot be sent after headers have already been sent (output started at /in/pfKge:24) in /in/pfKge on line 76 1
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: session_id(): Cannot change session id when session is active in /in/pfKge on line 24 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/pfKge:24) in /in/pfKge on line 76 1
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33
1 newsessionid

preferences:
144.84 ms | 402 KiB | 184 Q