3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php foreach(get_defined_vars()as $key => $v) { unset($GLOBALS[$key]); } unset($key, $v); $a=5; $b = 6; $count = count(get_defined_vars()); $new = 8; $vars=array_slice(get_defined_vars(), $count); var_dump($vars);
Output for 4.3.0 - 4.4.9, 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { ["count"]=> int(2) ["new"]=> int(8) }
Output for 5.0.4 - 5.3.29
Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 array(2) { ["count"]=> int(17) ["new"]=> int(8) }
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 Notice: Undefined variable: GLOBALS in /in/Bd3oM on line 6 array(2) { ["count"]=> int(17) ["new"]=> int(8) }