title: Why is not possible for a child class to inherit properties class that are set dynamically?
body: <p>Inheritance of properties is possible when a property is hardcoded.  See below:</p>
  
  <pre><code>class ParentObj {   
  
      protected $familyName = 'Lincoln';   
  
  }   
  
  class ChildObj extends ParentObj {   
  
      public function __construct() {   
          var_dump($this-&gt;familyName);  
      }   
  }   
  
  $childObj = new ChildObj();   
  
  // OUTPUT 
  string 'Lincoln'
  </code></pre>
  
  <p>Inheritance of properties is not possible when a property is dynamic. See below: </p>
  
  <pre><code>class ParentObj {   
  
      protected $familyName; 
  
      public function setFamilyName($familyName){  
          $this-&gt;familyName = $familyName;  
      } 
  
  }   
  
  class ChildObj extends ParentObj {   
  
      public function __construct() {   
          var_dump($this-&gt;familyName);  
      }   
  }   
  
  $familyName = 'Lincoln';  
  $parentObj = new ParentObj();  
  $parentObj-&gt;setFamilyName($familyName); 
  
  $childObj = new ChildObj(); 
  
  // OUTPUT
  null
  </code></pre>
  
  <p>So the question is: Why is not possible for a child class to inherit properties class that are set dynamically?</p>