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
Post a Comment