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:112211');
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/4TAA3 on line 72 and exactly 2 expected in /in/4TAA3:29 Stack trace: #0 /in/4TAA3(72): MemcacheSessionModule->open('unix:///var/run...') #1 {main} thrown in /in/4TAA3 on line 29
Process exited with code 255.
Output for 5.3.3 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
Warning: Missing argument 2 for MemcacheSessionModule::open(), called in /in/4TAA3 on line 72 and defined in /in/4TAA3 on line 29 array(3) { ["scheme"]=> string(4) "file" ["path"]=> string(22) "/var/run/memcache.sock" ["query"]=> string(10) "weight=123" } bool(false)
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.2
Warning: Missing argument 2 for MemcacheSessionModule::open(), called in /in/4TAA3 on line 72 and defined in /in/4TAA3 on line 29 array(3) { ["scheme"]=> string(4) "file" ["path"]=> string(22) "/var/run/memcache.sock" ["query"]=> string(10) "weight=123" } Warning: parse_url(tcp://127.0.0.1:112211): Unable to parse URL in /in/4TAA3 on line 65 bool(false)
Output for 5.1.0 - 5.1.6
Warning: Missing argument 2 for MemcacheSessionModule::open(), called in /in/4TAA3 on line 72 and defined in /in/4TAA3 on line 29 array(3) { ["scheme"]=> string(4) "file" ["path"]=> string(22) "/var/run/memcache.sock" ["query"]=> string(10) "weight=123" } Warning: parse_url(tcp://127.0.0.1:112211): Unable to parse url in /in/4TAA3 on line 65 bool(false)
Output for 5.0.0 - 5.0.5
Warning: Missing argument 2 for MemcacheSessionModule::open() in /in/4TAA3 on line 29 array(3) { ["scheme"]=> string(4) "file" ["path"]=> string(22) "/var/run/memcache.sock" ["query"]=> string(10) "weight=123" } Warning: parse_url(tcp://127.0.0.1:112211): Unable to parse url in /in/4TAA3 on line 65 bool(false)
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/4TAA3 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/4TAA3 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/4TAA3 on line 5
Process exited with code 255.

preferences:
338.48 ms | 401 KiB | 451 Q