3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $testVar = 'foo'; $var2 = 'two'; // 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);
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
array(4) { ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for hhvm-3.10.0 - 3.12.0
array(7) { ["HTTP_RAW_POST_DATA"]=> NULL ["_REQUEST"]=> array(0) { } ["_SESSION"]=> array(0) { } ["argc"]=> int(1) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.3.29
array(11) { ["HTTP_ENV_VARS"]=> array(9) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" } ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["HTTP_SERVER_VARS"]=> array(17) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" ["PHP_SELF"]=> string(9) "/in/gf8PM" ["SCRIPT_NAME"]=> string(9) "/in/gf8PM" ["SCRIPT_FILENAME"]=> string(9) "/in/gf8PM" ["PATH_TRANSLATED"]=> string(9) "/in/gf8PM" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME"]=> int(1410555607) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) } ["HTTP_POST_FILES"]=> array(0) { } ["_REQUEST"]=> array(0) { } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.3.27 - 5.3.28
array(11) { ["HTTP_ENV_VARS"]=> array(9) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" } ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["HTTP_SERVER_VARS"]=> array(17) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" ["PHP_SELF"]=> string(9) "/in/gf8PM" ["SCRIPT_NAME"]=> string(9) "/in/gf8PM" ["SCRIPT_FILENAME"]=> string(9) "/in/gf8PM" ["PATH_TRANSLATED"]=> string(9) "/in/gf8PM" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME"]=> int(1402811564) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) } ["HTTP_POST_FILES"]=> array(0) { } ["_REQUEST"]=> array(0) { } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.3.7 - 5.3.26
array(11) { ["HTTP_ENV_VARS"]=> array(9) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" } ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["HTTP_SERVER_VARS"]=> array(17) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" ["PHP_SELF"]=> string(9) "/in/gf8PM" ["SCRIPT_NAME"]=> string(9) "/in/gf8PM" ["SCRIPT_FILENAME"]=> string(9) "/in/gf8PM" ["PATH_TRANSLATED"]=> string(9) "/in/gf8PM" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME"]=> int(1402811565) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) } ["HTTP_POST_FILES"]=> array(0) { } ["_REQUEST"]=> array(0) { } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.2.3 - 5.3.6
array(11) { ["HTTP_ENV_VARS"]=> array(9) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" } ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["HTTP_SERVER_VARS"]=> array(17) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" ["PHP_SELF"]=> string(9) "/in/gf8PM" ["SCRIPT_NAME"]=> string(9) "/in/gf8PM" ["SCRIPT_FILENAME"]=> string(9) "/in/gf8PM" ["PATH_TRANSLATED"]=> string(9) "/in/gf8PM" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME"]=> int(1402811566) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) } ["HTTP_POST_FILES"]=> array(0) { } ["_REQUEST"]=> array(0) { } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.2.1 - 5.2.2
array(11) { ["HTTP_ENV_VARS"]=> array(9) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" } ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["HTTP_SERVER_VARS"]=> array(13) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" ["PHP_SELF"]=> string(0) "" ["REQUEST_TIME"]=> int(1402811566) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) } ["HTTP_POST_FILES"]=> array(0) { } ["_REQUEST"]=> array(0) { } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.1.0 - 5.2.0
array(11) { ["HTTP_ENV_VARS"]=> array(9) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" } ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["HTTP_SERVER_VARS"]=> array(13) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIN"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["USERNAME"]=> string(6) "nobody" ["HOME"]=> string(1) "/" ["PHP_SELF"]=> string(0) "" ["REQUEST_TIME"]=> int(1402811567) ["argv"]=> array(1) { [0]=> string(9) "/in/gf8PM" } ["argc"]=> int(1) } ["HTTP_POST_FILES"]=> array(0) { } ["_REQUEST"]=> array(0) { } ["testVar"]=> string(3) "foo" ["var2"]=> string(3) "two" }
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function array_diff_key() in /in/gf8PM on line 7
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: array_diff_key() in /in/gf8PM on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: array_diff_key() in /in/gf8PM on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: array_diff_key() in /in/gf8PM on line 7