Better explanation of $this-> in this example please

Posted by Doug on Stack Overflow See other posts from Stack Overflow or by Doug
Published on 2010-04-09T03:51:34Z Indexed on 2010/04/09 4:03 UTC
Read the original article Hit count: 256

Filed under:
|

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);
        }

© Stack Overflow or respective owner

Related posts about php5

Related posts about oop