php - $GLOBALS superglobal gets modified when passed to a function -
i came across weird behavior in php:
function f($var) { // not using references foreach ($var $k => $v) { unset($var[$k]); // shouldn't unset copy?! } } print '<pre>'; var_dump($globals); // array f($globals); var_dump($globals); // null?!
anybody know why happening?
print out it’s deleting , enable warnings see what’s happening! =)
$globals
contains globals
. unset
it, removes actual global variable. if just pass-by-reference behaviour, empty array, not null
.
Comments
Post a Comment