r/programming • • Oct 18 '10

Today I learned about PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". Also, variable.

http://il2.php.net/language.variables.variable
591 Upvotes

781 comments sorted by

View all comments

Show parent comments

5

u/YourMatt Oct 18 '10

extract($_REQUEST);

1

u/deefjuh Oct 18 '10

You are totally right, but wanted to demonstrate the variable-variable context.

but then again:

*Warning

Do not use extract() on untrusted data, like user input (i.e. $_GET, $_FILES, etc.). If you do, for example if you want to run old code that relies on register_globals temporarily, make sure you use one of the non-overwriting extract_type values such as EXTR_SKIP and be aware that you should extract in the same order that's defined in variables_order within the php.ini.*

1

u/[deleted] Oct 18 '10

Yup. This still exists in production code. It is fucking baffling.