Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the use of constructor in abstract class in php
    primarykey
    data
    text
    <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="nofollow 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="nofollow 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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload