PHP extract

Started on the old forum in May 2012 · view the original in the archive · old links redirect here

3 replies · 558 views · started 14 years ago · 1 min read

3 participants
shushant Developer · 207 posts #1

Which is better

foreach ($_GET as $k => $v){ 
$$k = $v;
} 
or
extract( $_GET );

why?

CreativityKills Lead · 833 posts #2

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 Newbie · 4 posts #3

i think its same only.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close