title: PHP Extending Classes and Sibling Access
body: <p>Alright, so I'm trying to figure out how to structure my code most efficiently. I've recently switched it from one giant class file with all my methods, to more smaller files that are combined with one base class. This is what I want, however I cannot get it to work properly and I need some help with the structure.</p>
  
  <p>Essentially I need to do this:</p>
  
  <ul>
  <li>There will be some functions that are just "tools" for the other classes (such as converter functions, etc.) - they need to be accessible by all the child classes.</li>
  <li>In some cases "child class one" will need to use functions from "child class two".</li>
  <li>A child class needs to be able to set a variable that another child classes can see.</li>
  </ul>
  
  <p>Please let me know how I can get started with these requirements; code examples would be greatly appreciated!</p>
  
  <p>Perhaps some pseudo code will help - but if I'm off please let me know what would work better!</p>
  
  <pre><code>class main {
      private $test;
      public function __construct() {
          //do some stuff
      }
      public function getTest() {
          echo('public call: '.$this-&gt;test);
      }
      private function randomFunc(){
          echo('hello');
      }
  }
  class child1 extends main {
      public function __construct() {
          parent::$test = 'child1 here';
      }
  }
  class child2 extends main {
      public function __construct() {
          echo('private call: '.parent::$test); //i want this to say "private call: child1 here"
          parent::randomFunc();
      }
  }
  $base = new main;
  new child1;
  new child2;
  $base-&gt;getTest();
  </code></pre>
  
  <p>So I want the result of that to be:</p>
  
  <pre><code>private call: child1 here
  hello
  public call: child1 here
  </code></pre>
  
  <p>So far what I've tried doesn't work... Please help! Thank you.</p>