php - foreach $_POST.. is this bad? -


is bad practice use use foreach make array of post data vs defining posts accepting?

 class foo {       function __construct()     {         foreach($_post $key => $var)         {             $this->post[] = $key = $var;         }      }      function bar()     {         echo $this->post['postdata'];     }  }        

vs;

 class foo {       function __construct()     {         $this->post = array(           "postdata" => $_post['postdata']         );     }      function bar()     {         echo $this->post['postdata'];     }  }        

there no great harm in automatically processing of posted fields, long processing limited storing in hash. matter of fact, can make fore easier maintain code.

the moment start doing (especially system related) data, need validate.


Comments

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

jQuery clickable div with working mailto link inside -