PHP extract
Started on the old forum in May 2012 · view the original in the archive · old links redirect here
shushant wrote: Which is better
foreach ($_GET as $k => $v){ $$k = $v; } or extract( $_GET );why?
Depends on the scope of your work but i usually try to avoid both methods. Its usually better to just use the cinventional $var = $_GET['key'] in time you will get to see that fetching all the values in $_GET can be bad. I just try to avoid lazy coding at all costs.
arevel wrote: i think its same only.
Its not. extract() takes away your control. With manually retrieving it, you pass to your script only the keys you need.