Bluehost.com Web Hosting $6.95

PHP5 class en many objects

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. ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2006
Marcel
 
Posts: n/a
Default PHP5 class en many objects

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>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:42 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0