title: How can I make different methods in my form-builder class?
body: <p>If I create a new PHP class e.g. to simplify form building (yes I know there are some out there) but I am also trying to learn about classes so pls. be patient - thanks ...</p>
  
  <p>OK I create a new class in the usual way </p>
  
  <p><code>class newform {</code> class details in here <code>}</code> </p>
  
  <p>add a construct function </p>
  
  <p><code>public function __construct() {</code> function in here <code>}</code>  </p>
  
  <p>I can then call that class again in the usual way </p>
  
  <p><code>$newform = new newform();</code> </p>
  
  <p>so far so good .... (for me anyhow). </p>
  
  <p>Now I can add some args to the function like so </p>
  
  <p><code>public function __construct($args) {</code> function in here <code>}</code></p>
  
  <p>and inside the function "go through" the args - which in my case is an array so written like this</p>
  
  <p><code>$newform = new newform($args = array('arg1'=&gt;'arg1 val','arg2'=&gt;'arg2 val'));</code></p>
  
  <p>I can do all that but how do I "add further functions"  What I mean here is at the moment I have to declare a new class for every input: i.e.</p>
  
  <pre><code>$newform = new newform($args = array('arg1'=&gt;'arg1 val','arg2'=&gt;'arg2 val'));
  $newform-&gt;textarea;
  
  $newform = new newform($args = array('arg1'=&gt;'arg1 val','arg2'=&gt;'arg2 val'));
  $newform-&gt;textinput;
  </code></pre>
  
  <p>That seems "very" long winded to me and therefore wrong.</p>
  
  <p>How do you do something like this (syntax I know is wromg) where textarea and textinput are created in the class a bit like this (but without the args) <code>$this-&gt;textarea = '&lt;textarea&gt;&lt;/textarea&gt;';</code></p>
  
  <pre><code>$newform = new newform();
  $newform-&gt;textarea($args);
  $newform-&gt;textinput($args);
  $newform-&gt;textarea($args);
  </code></pre>
  
  <p>What I mean is what additional function/s do you put into the class to allow you to firstly declare the class (<code>$newform = new newform();</code>) then pass $args to items within the class so you can do "something" like above?</p>
  
  <p>Hope I am explaining myself.</p>