title: Php Inheritance
body: <p>I am using PHP 5.3 stable release and sometimes I encounter very inconsistent behaviours. As far as I know in inheritance all attributes and methods(private, public and protected) in super class are passed child class.</p>
  
  <pre><code>class Foo
  {
      private $_name = "foo";
  }
  class Bar extends Foo
  {
      public function getName()
      {
          return $this-&gt;_name;
      }
  }
  $o = new Bar();
  echo $o-&gt;getName();
  
  //Notice: Undefined property: Bar::$_name in ...\test.php on line 11
  </code></pre>
  
  <p>But when Foo::$_name attribute is defined "public" it doesn't give error. PHP has own OO rules???</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit:</strong> Now all things are clear.
  Actually I was thinking in "inheritance" a new class is created and inherits all members independent from its ancestor. I didn't know "accessing" rules and inheritance rules are the same.</p>
  
  <p><strong><em>Edit</em></strong>
  According to your comments this snippet should give an error. But it is working.</p>
  
  <pre><code>class Foo
  {
      private $bar = "baz";
  
      public function getBar()
      {
          return $this-&gt;bar;
      }
  }
  
  class Bar extends Foo
  {}
  
  $o = new Bar;
  echo $o-&gt;getBar();      //baz
  </code></pre>