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

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -