3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Session_Database{ public function close(){} } class Session { private Session_Database $db; public function __construct(){ // Instantiate new Database object $this->db = new Session_Database(); // Set handler to overide SESSION session_set_save_handler( [$this, '_open'], [$this, '_close'], [$this, '_read'], [$this, '_write'], [$this, '_destroy'], [$this, '_gc'] ); // Start the session session_start(); } public function _open(string $savePath, string $sessionName): bool {return true;} public function _read(string $sessionId): string {return '';} public function _write(string $sessionId, string $data): bool {return true;} public function _destroy(string $sessionId): bool {return true;} public function _gc(int $lifetime): bool {return true;} public function _close(): bool { echo 'closing session'; // Close the database connection $this->db->close(); return true; } } new Session; session_write_close();
Output for git.master, git.master_jit
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in /in/WfN3S on line 15 Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in /in/WfN3S on line 15 Warning: session_start(): Session cannot be started after headers have already been sent in /in/WfN3S on line 25
Output for rfc.property-hooks
closing session

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:
40.9 ms | 983 KiB | 4 Q