title: PHP classes and include
body: <p><strong>I have the following question:</strong></p>
  
  <p>This is my main file <code>index.php</code>.</p>
  
  <pre><code>&lt;?php
  
  class myClass
  {
    function myClass()
    {
      echo '[constructor]';
      $this-&gt;myVar = '[i am making a test]';
      $this-&gt;A();
    }
    function A()
    {
      echo '[function A works too]';
      echo $this-&gt;myVar;
    }
  }
  
  $test = new myClass;
  
  ?&gt;
  </code></pre>
  
  <p>Now I need to move <code>function A</code> into another PHP file <code>includes/function_a.php</code> which I could <strong>include_once</strong> in the main file. The reason is to make my main file smaller and easier to read.</p>
  
  <p>What is the best practice of having this done, EXTENDS?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've done this using EXTENDS:</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php
  
  include_once('includes/function_a.php');
  
  class myClass extends anotherClass
  {
    function myClass()
    {
      echo '[constructor]';
      $this-&gt;myVar = '[i am making a test]';
      $this-&gt;A();
    }
  }
  
  $test = new myClass;
  
  ?&gt;
  </code></pre>
  
  <p><strong>includes/function_a.php</strong></p>
  
  <pre><code>&lt;?php 
  class anotherClass
  {
    function A()
    {
      echo '[function A works too]';
      echo $this-&gt;myVar;
    }
  }
  ?&gt;
  </code></pre>
  
  <p>Any better ideas?</p>