什么是Python的本地人()的PHP等价物?

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...]
)

get_defined_vars is what you're looking for.

function test(){
    $a = 'local';
    $b = 'another';
    print_r(get_defined_vars());
}

test();

#Array
#(
#    [a] => local
#    [b] => another
#)