run code in 150+ php & hhvm versions
Bugs & Features
<?php $testVar = 'foo'; // list of keys to ignore (including the name of this variable) $ignore = array('GLOBALS', '_FILES', '_COOKIE', '_POST', '_GET', '_SERVER', '_ENV', 'ignore'); // diff the ignore list as keys after merging any missing ones with the defined list $vars = array_diff_key(get_defined_vars() + array_flip($ignore), array_flip($ignore)); // should be left with the user defined var(s) (in this case $testVar) var_dump($vars); // Result: array(1) { ["testVar"]=>string(3) "foo" }
Output for 5.3.0 - 5.4.29
Parse error: syntax error, unexpected '{' in /in/i0B0k on line 11
Process exited with code 255.