The definition is mentioned above, now I will try to give you an example:
"abstract" ensures that you follow a specific logic, e.g. a ticket s material is ALWAYS "paper", or a creditcard must always have a "code".
This is important if you work in a big company which has strict standardisation or if you want to force your developers to follow a specific structure, so their code won t end up in a mess.
abstract class ticket{
public function material()
{
return Paper ;
}
}
abstract class creditcard{
public function material()
{
return Plastic ;
}
abstract function setCode(); // the ";" semicolon is important otherwise it will cause an error
}
class key extends ticket{
public function getMaterial()
{
return parent::material();
}
}
class anotherKey extends creditcard{
public function setCode($code)
{
$this->code = $code;
}
}
If we do not define the "setCode" method the parser will return an error on "new anotherKey
"