3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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');
based on FVfbA
Output for 7.1.0
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 - 7.0.14
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.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.