title: Base class not permitted to access private member?
body: <p>I could have sworn that in standard OOP, you can access the private members of the concrete class from a method in the base class. Does PHP just implement this differently, or am I doing something wrong, or was my understanding entirely wrong?</p>
  
  <pre><code>&lt;?php
  
  class Base {
    public function __toString() {
      return $this-&gt;name;
    }
  }
  
  class Concrete extends Base {
    private $name;
  
    public function __construct($name) {
      $this-&gt;name = $name;
    }
  }
  
  $o = new Concrete('foobar');
  echo $o;
  </code></pre>
  
  <p>The above code fragment throws <code>Fatal error: Cannot access private property Concrete::$name on line 5</code>. It works if I change the access level of <code>$name</code> to <code>protected</code>. </p>
  
  <p><a href="http://codepad.org/4KeXPUvi" rel="nofollow">Demo</a></p>