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']"; } eval("$key = &$_SESSION{$sessionKey} = $value"); $_SESSION{$sessionKey} = $value; var_dump($key); return !empty(self::getKey($sessionKey)); } setKey('1:2:3', 77);
based on AMFr2
Output for 7.0.0 - 7.0.2
Fatal error: Cannot use "self" when no class scope is active in /in/aWu57 on line 15
Process exited with code 255.
Output for 5.5.24 - 5.6.17
Notice: Undefined variable: _SESSION in /in/aWu57 on line 10 Parse error: syntax error, unexpected '=' in /in/aWu57(10) : eval()'d code on line 1 string(1) "3" Fatal error: Cannot access self:: when no class scope is active in /in/aWu57 on line 15
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/aWu57 on line 15
Process exited with code 255.