title: php class extends, variable from other extended class
body: <p>I have a main class and two extended classes:</p>
  
  <pre><code>class Main {
      public $foo;
  }
  
  class A extends Main {
    public function setVar()
      {
        $foo = "test"; 
      }
  }
  
  class B extends Main {
    public function getVar()
      {
        return $this-&gt;foo;
      }
  }
  
  $A = new A;
  $B = new B;
  
  $A-&gt;setVar();
  
  echo "result: ".$B-&gt;getVar();
  </code></pre>
  
  <p>But result ($B->getVar()) stays empty. I am clearly missing something simple here... Besides that, is this the way to go splitting long classes up in relevant subclasses?</p>