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