3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function setKey($sessionKeys, $value) { $sessionKeysArray = explode(':', $sessionKeys); $sessionKey = ''; foreach ($sessionKeysArray as $key){ $sessionKey .= "[\'$key\']"; } echo eval('&$_SESSION' . $sessionKey . ' = ' . $value . ';'); var_dump($_SESSION); return !empty(self::getKey($sessionKey)); } setKey('1:2:3', 77);
based on OvUvL
Output for 7.0.0 - 7.0.2
Fatal error: Cannot use "self" when no class scope is active in /in/CT9Cj on line 14
Process exited with code 255.
Output for 5.5.24 - 5.6.17
Parse error: syntax error, unexpected '&' in /in/CT9Cj(11) : eval()'d code on line 1 Notice: Undefined variable: _SESSION in /in/CT9Cj on line 12 NULL Fatal error: Cannot access self:: when no class scope is active in /in/CT9Cj on line 14
Process exited with code 255.
Output for 5.3.21 - 5.4.45
Fatal error: Can't use function return value in write context in /in/CT9Cj on line 14
Process exited with code 255.