I followed this link already before asking - Answer is in JAVA context and this for constructor in PHP .
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.
Please provide an example in real world context to grab the concept better.
PS - Although I am following PHP Manuals 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.
My Code -
<?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!!!","<br />";
}
public function getValue()
{
echo "Zero is the blackhole for the numbers!!","<br />";
}
}
class childClass extends parentClass
{
function raiseFlag()
{
echo "Peaceful thoughts!!","<br />";
}
}
$myobj = new childClass();
$myobj->raiseFlag();
$myobj->getValue();
$myobj->grandmethod();