3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MemcacheSessionModule /*implements \SessionHandlerInterface */ { const UNIX_PREFIX = 'unix://'; const FILE_PREFIX = 'file://'; /** * Our Memcache Pool * @var Memcache */ private $pool; public function close() { if ($this->pool instanceof Memcache) { return $this->pool->close(); } return true; } public function destroy($sessionId) { } public function gc($maxLifetime) { } public function open($savePath, $name) { $serverList = self::parseSavePath($savePath); if (!$serverList) { return false; } foreach ($serverList as $serverInfo) { } } public function read($sessionId) { } public function write($sessionId, $data) { } private static function parseSavePath($savePath) { if (empty($savePath)) { trigger_error( "Failed to parse session.save_path (empty save_path)", E_WARNING); return false; } $return = array(); $serverList = explode(',', $savePath); foreach ($serverList as $url) { // Swap unix:// to file:// for parse_url if (strtolower(substr($url, 0, strlen(self::UNIX_PREFIX))) === self::UNIX_PREFIX) { $url = self::FILE_PREFIX . substr($url, strlen(self::UNIX_PREFIX)); } $parsedUrlData = parse_url($url); var_dump($parsedUrlData); } } } $session = new MemcacheSessionModule; $session->open('unix:///var/run/memcache.sock?weight=123,tcp://127.0.0.1:11211?weight=1&persistent=1&timeout=4');
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught ArgumentCountError: Too few arguments to function MemcacheSessionModule::open(), 1 passed in /in/UXle0 on line 72 and exactly 2 expected in /in/UXle0:29 Stack trace: #0 /in/UXle0(72): MemcacheSessionModule->open('unix:///var/run...') #1 {main} thrown in /in/UXle0 on line 29
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20
Warning: Missing argument 2 for MemcacheSessionModule::open(), called in /in/UXle0 on line 72 and defined in /in/UXle0 on line 29 array(3) { ["scheme"]=> string(4) "file" ["path"]=> string(22) "/var/run/memcache.sock" ["query"]=> string(10) "weight=123" } array(4) { ["scheme"]=> string(3) "tcp" ["host"]=> string(9) "127.0.0.1" ["port"]=> int(11211) ["query"]=> string(31) "weight=1&persistent=1&timeout=4" }
Output for 5.0.0 - 5.0.5
Warning: Missing argument 2 for MemcacheSessionModule::open() in /in/UXle0 on line 29 array(3) { ["scheme"]=> string(4) "file" ["path"]=> string(22) "/var/run/memcache.sock" ["query"]=> string(10) "weight=123" } array(4) { ["scheme"]=> string(3) "tcp" ["host"]=> string(9) "127.0.0.1" ["port"]=> int(11211) ["query"]=> string(31) "weight=1&persistent=1&timeout=4" }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UXle0 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UXle0 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/UXle0 on line 5
Process exited with code 255.

preferences:
237.8 ms | 401 KiB | 356 Q