title: What is the use of constructor in abstract class in php
body: <p>I followed this link already before asking - <a href="https://stackoverflow.com/questions/2105783/what-is-the-use-of-creating-a-constructor-for-an-abstract-class-in-java">Answer is in JAVA context</a> and this for <a href="http://php.net/manual/en/language.oop5.decon.php" rel="noreferrer">constructor in PHP</a> .</p>
  
  <p>Since I am starter, my implementation of my PHP code in OOP concepts, so I am really willing to know about the usage and benefits or when to use constructor in PHP abstract class.</p>
  
  <p>Please provide an example in real world context to grab the concept better.</p>
  
  <p>PS - Although I am following <a href="http://php.net/manual/en/language.oop5.php" rel="noreferrer">PHP Manuals</a> to understand OOP concepts but I am finding it little bit hard to understand, any help with the links/blog to follow is really appreciable.</p>
  
  <p>My Code -</p>
  
  <pre><code>&lt;?php
  
  abstract class grandClass
  {
      abstract function grandmethod();
  
      function __construct()
      {
          echo "I am grandClass constructor";
      }
  }
  
  abstract class parentClass extends grandClass
  {
      abstract function raiseFlag();
  
      function grandmethod()
      {
          echo "This is grandmethod!!!","&lt;br /&gt;";
      } 
  
      public function getValue()
      {
          echo "Zero is the blackhole for the numbers!!","&lt;br /&gt;";
      }
  }
  
  class childClass extends parentClass
  {
  
      function raiseFlag()
      {
          echo "Peaceful thoughts!!","&lt;br /&gt;";
      }
  
  }
  
  $myobj = new childClass();
  $myobj-&gt;raiseFlag();
  $myobj-&gt;getValue();
  $myobj-&gt;grandmethod(); 
  </code></pre>