title: Passing data between classes in PHP
body: <p>A couple of questions: q1:</p>
  
  <p>IN OOP PHP, what is the best way for a child class to make use of a var set by the parent class, and to set a variable in the parent class.</p>
  
  <p>What I want to do is run a function in the child class, that uses one of the variables in the parent class.</p>
  
  <p>I have done it by setting the variable I want to access as public, and entering it into the child class as an argument when calling the function, but it would be better if I could simply get it within the child class's function.</p>
  
  <p>Then, to set the variable in the parent class with the result of that function, I have returned the value into a setter class of the parent function. Here it is all in action:</p>
  
  <pre><code>$parentClass-&gt;set_maxpages($childClass-&gt;setMaxPages($cparentClass-&gt;contents));
  </code></pre>
  
  <p>Q2:</p>
  
  <p>When I instantiate the child class, it runs the paren'ts constructor. If the child class has a constructor of its own, does it override the parnt class constructor.</p>