Referring to this question: http://stackoverflow.com/questions/2035449/why-is-oop-hard-for-me
class Form
{
protected $inputs = array();
public function makeInput($type, $name)
{
echo '<input type="'.$type.'" name="'.$name.'">';
}
public function addInput($type, $name)
{
$this->inputs[] = array("type" => $type,
"name" => $name);
}
public function run()
{
foreach($this->inputs as $array)
{
$this->makeInput($array['type'], $array['name'];
}
}
}
$form = new form();
$this->addInput("text", "username");
$this->addInput("text", "password");**
Can I get a better explanation of what the $this->input[]
is doing in this part:
public function addInput($type, $name)
{
$this->inputs[] = array("type" => $type,
"name" => $name);
}