This is a discussion on PHP5 class en many objects within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I have a question: I have made a PHP5 class that creates en print outs a HTML form textfield. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I have a question: I have made a PHP5 class that creates en print outs a HTML form textfield. See code below. Now my form needs about 200 textfields. What will this do to the performance as i need to create 200 new objects from my class. Can that be done without problems or will this decrease performance significant? Regards, Marcel # code: class mca_number_field { private $name; private $value; protected $error; public function __construct($name,$value) { $this->name = $name; $this->value = $value; } public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } public function setValue($value) { $this->value = $value; } public function getValue() { return $this->value; } public function setError($bool) { $this->error = $bool; } public function getError() { return $this->error; } public function output() { if($this->error) { echo '<input type="text" name="'.$this->name.'" value="'.$this->value.'" style="color:red" />'; } else { echo '<input type="text" name="'.$this->name.'" value="'.$this->value.'" />'; } } } class numberfield extends mca_number_field { public function checkInput($input) { if(!ereg("^[1-9][0-9]*$",$input)) { $this->error = true; } } } ?> <form id="form1" name="form1" method="post" action="mca_tf.php"> <?php # using default constructor $numberfieldx = new numberfield('test',$_POST['test']); $numberfieldx->checkInput($_POST['test']); $numberfieldx->output(); ?> <input type="submit" name="Submit" value="Submit" /> </form> |