3v4l.org

run code in 300+ PHP versions simultaneously
<?php function unset_globals($array) { if(!is_array($array)) { return; } foreach(array_keys($array) as $key) { unset($GLOBALS[$key]); unset($GLOBALS[$key]); // Double unset to circumvent the zend_hash_del_key_or_index hole in PHP <4.4.3 and <5.1.4 } } $ryat = 'haha'; //var_dump($GLOBALS); $_GET['GLOBALS'] = 'hi'; $_GET['ryat'] = 'hi'; $_GET['_COOKIE'] = 'hi'; //var_dump($GLOBALS); unset_globals($_GET); var_dump($GLOBALS); echo $ryat; var_dump($_COOKIE);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(6) { ["_GET"]=> array(3) { ["GLOBALS"]=> string(2) "hi" ["ryat"]=> string(2) "hi" ["_COOKIE"]=> string(2) "hi" } ["_POST"]=> array(0) { } ["_FILES"]=> array(0) { } ["argv"]=> array(1) { [0]=> string(9) "/in/gX15c" } ["argc"]=> int(1) ["_SERVER"]=> array(17) { ["TERM"]=> string(5) "xterm" ["PATH"]=> string(13) "/usr/bin:/bin" ["LANG"]=> string(1) "C" ["SHELL"]=> string(7) "/bin/sh" ["MAIL"]=> string(16) "/var/mail/nobody" ["LOGNAME"]=> string(6) "nobody" ["USER"]=> string(6) "nobody" ["HOME"]=> string(4) "/tmp" ["PHP_SELF"]=> string(9) "/in/gX15c" ["SCRIPT_NAME"]=> string(9) "/in/gX15c" ["SCRIPT_FILENAME"]=> string(9) "/in/gX15c" ["PATH_TRANSLATED"]=> string(9) "/in/gX15c" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME_FLOAT"]=> float(1394082344.0001) ["REQUEST_TIME"]=> int(1394082344) ["argv"]=> array(1) { [0]=> string(9) "/in/gX15c" } ["argc"]=> int(1) } } Warning: Undefined variable $ryat in /in/gX15c on line 23 Warning: Undefined global variable $_COOKIE in /in/gX15c on line 24 NULL
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $GLOBALS in /in/gX15c on line 12 Warning: Undefined variable $GLOBALS in /in/gX15c on line 11 Warning: Undefined variable $GLOBALS in /in/gX15c on line 12 Warning: Undefined variable $GLOBALS in /in/gX15c on line 11 Warning: Undefined variable $GLOBALS in /in/gX15c on line 12 Warning: Undefined variable $GLOBALS in /in/gX15c on line 22 NULL hahaarray(0) { }
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined variable: GLOBALS in /in/gX15c on line 12 Notice: Undefined variable: GLOBALS in /in/gX15c on line 11 Notice: Undefined variable: GLOBALS in /in/gX15c on line 12 Notice: Undefined variable: GLOBALS in /in/gX15c on line 11 Notice: Undefined variable: GLOBALS in /in/gX15c on line 12 Notice: Undefined variable: GLOBALS in /in/gX15c on line 22 NULL hahaarray(0) { }
Output for 7.3.32 - 7.3.33, 7.4.26
NULL hahaarray(0) { }
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: GLOBALS in /in/gX15c on line 12 Notice: Undefined variable: GLOBALS in /in/gX15c on line 11 Notice: Undefined variable: GLOBALS in /in/gX15c on line 12 Notice: Undefined variable: GLOBALS in /in/gX15c on line 11 Notice: Undefined variable: GLOBALS in /in/gX15c on line 12 Notice: Undefined variable: GLOBALS in /in/gX15c on line 22 NULL hahaarray(0) { }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
Notice: Undefined variable: GLOBALS in /in/gX15c on line 22 NULL Notice: Undefined variable: ryat in /in/gX15c on line 23 Notice: Undefined variable: _COOKIE in /in/gX15c on line 24 NULL

preferences:
261.25 ms | 402 KiB | 373 Q