I know $GLOBALS
in PHP is a rough equivalent of Python's globals()
, but is there an equivalent of locals()
?
My Python:
>>> g = 'global'
>>> def test():
... l = 'local'
... print repr(globals());
... print repr(locals());
...
>>>
>>> test()
{'g': 'global', [...other stuff in the global scope...]}
{'l': 'local'}
My PHP port:
<?php
$g = 'global';
function test(){
$l = 'local';
print_r($GLOBALS);
//...please fill in the dots...:-)
}
test();
?>
Array
(
[g] => global
[...other stuff in the global scope...]
)