php $$ operator

Possible Duplicate:
What does $$ mean in PHP?

I can't find documentation for this anywhere. You'd think it would be easy!

I came across this piece of code when reading through a webmail client framework (favourite pass time hobby) and i dont know what $$ means...

if (isset($_POST)){
while ( list($var, $val) = each($_POST) ) $$var = input_filter($var,$val);
}

Could somebody also explain basically what this does?

My interpretation is

if post is set
    loop until end of $_POST
        initialise each $_POST as a variable,
        filter variables
    end loop
end if

http://www.php.net/manual/en/language.variables.variable.php


it's basically mimicing "register globals" for POST. $$var means take whatever $var evaluates to (it's a string) and make a variable of that name. So if $var is "email" then $$var is the same as $email.

链接地址: http://www.djcxy.com/p/59098.html

上一篇: 在PHP中有指针吗?

下一篇: php $$操作符