PHP extract

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP extract

    Which is better
    Code:
    foreach ($_GET as $k => $v){ 
    $$k = $v;
    } 
    or
    extract( $_GET );
    why?

    #2
    Originally posted by shushant View Post
    Which is better
    Code:
    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.

    Comment


      #3
      i think its same only.

      Comment


        #4
        Originally posted by arevel View Post
        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.

        Comment

        Working...
        X