For C ++ 11, at least [=] () {...} will automatically pull out all and only those local variables that the function body uses. (Or, equally, [&]... )
You can specify individual variables that should be written by reference or by value if you have any specific needs that go beyond this catch-all.
In PHP, variables are created when their name is first used, so I expect the declaration to make sure that new variables do not mask old ones. A bit like the global .
spraff
source share